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] ;


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

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



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
Tamagochi were all the rage in the 90's as a small toy that had limited functionality but modelled a pet. The "owner" could do the following • Feed the pet • Heal the pet

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Explain the Do - While Statement - Computer Programming? A do - while loop is an exit controlled loop and the body of the loop gets executed at least once if the condition is n

Man, i''m having quite a problem with this exercise. Even googled for Roman multiply table concept. I just don''t get it. Multiply two numbers given in Roman figures. For instan

fow to I write a emplate that reads a set of numbers typed at the keyboard into an array of T

I have to create a calorie counter and I am totally lost

1)      Go to Start -> Programs->Accessories->Notepad. 2)      Start with a document type tag & an opening tag. Enter the given line in your doc.

Really urgent help needed with Javascript. I have this website: I"> I need to remove the video on the slider so that it only sho

I need help programming an arduino uno to scan an ean-8 student barcode and display their name and id on computer. This is a capstone project.

How to i write a car rental program in jgrasp