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
What are the main pros and cons of assembly programming language?

Question 1 Discuss on UNIX kernel components 2 Explain process creation and process termination 3 When do a Deadlock occur? What are the Necessary Conditions for Deadlock

what is the optimal solution for this problem? Max 1A + 1B s.t. 5A +3B 3A + 5B A,B >0

Note: You should pay attention on following good practices: Appropriate code comments(If you make any assumptions clearly comment them in the code) Indentation

I am working on a matlab project and need help debugging one question i have written and need help working through another problem.

Expertsmind brings you unique solution in java assignments Reflection API Uses of Reflection with java assignment help Reflection is widely used by applications which

Design the proposed implementation using the contract first approach and object oriented approaches.  At a minimum, you must provide an overview of the services in the service arch

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the

Write a function that converts a character array to a signed floating point number. Function prototype must be as follows: int asciiToFloat( char *str, unsigned char* eflag) Follow

Need help with a cobol program.