Define a prolog predicate flatten, Programming Languages

Define a Prolog predicate flatten(List, FlattenedList) that asserts List is any nested list of atoms and FlattenedList is the same list with the nesting removed. The atom [] should also be removed. Your predicate should only produce one answer. You may use the built-in predicates not, ! and append. Do not use a helper predicate.

?- flatten([a, [[b,c],d], [[e]], [f]], X).

X = [a,b,c,d,e,f] ;

no

?- flatten([a,[[]], [[c,d],e]], X).

X = [a,c,d,e] ;

no

 

Posted Date: 3/28/2013 3:53:59 AM | Location : United States







Related Discussions:- Define a prolog predicate flatten, Assignment Help, Ask Question on Define a prolog predicate flatten, Get Answer, Expert's Help, Define a prolog predicate flatten Discussions

Write discussion on Define a prolog predicate flatten
Your posts are moderated
Related Questions
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Characteristics of procedure-oriented programming: Emphasis is on doing things (algorithms). Large programs are divided into smaller programs known as functions.

Write a program that takes names of 5 students in 2D Character Array and their GPAs in 1D array. Arrange the names in alphabetical order and display on screen along with GPA.

Write a Prolog predicate remove_nth(N,L1,L2) that is true if list L2 is just list L1 with its Nth element removed. If L1 does not have an Nth element then the predicate should fail

Web Services Information Language WCF is designed using assistance focused structure concepts to support allocated processing where solutions have distant customers. Customers can

Problem: This assignment is about deleting nodes from the binary search tree. You need to use given sequence to construct a binary search tree and then delete some nodes from

Hi I have an assignment for prolog languagle is it possible to get help


Write a Prolog predicate  has_duplicates(L)  that is true if list  L  contains duplicated elements (that is at least 2 copies of an element). For instance: ?- has_duplicates([a,

how do i make a bomber game using pascal on a software called lazuras