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
Introduction Currently, Omega has 178 stores UK wide. Most cities and large towns within the UK are catered for by Omega. Omega began in 1960's selling various makes of telep

Use recursion to de ne a function position which has as input an integer, a character and a string and returns the result of inserting the character in the string at the position s

what is a microprocessor? types of microprocessors? advantages disadvantages

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

maake a programme in C of HR system

Determine the solution to the following differential equation. x 2 y′′ + 3xy′ + 4 y = 0   Solution Find the roots to (3) first as generally. r(r -1) + 3r + 4 = 0 r

The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of t

Find out the selling cost average for packages developed in Pascal

Define Reasons for using Functions? 1. Evade rewriting the same code over and over. 2. It is simpler to write programs and keep track of what they are doing. Codes are able t

Write a program to read a text file and create a dictionary. The keys for the dictionary should be all 26 letters of the alphabet and the values of the dictionary should be the lis