Define a prolog predicate that asserts list, 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/22/2013 5:55:25 AM | Location : United States







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

Write discussion on Define a prolog predicate that asserts list
Your posts are moderated
Related Questions
Write a program to draw the truck following figure. The program should buttons to provide When the truck runs left wheels must rotate in the correct direction. Rotating whe

Object-oriented languages Languages that support OOP features can be classified into the following two categories: 1.    Object-based programming languages, and 2.      O

The ATM will simulate a real world automated teller machine that supports safe access to accounts from multiple concurrent clients.

Write a program that will generate 25 DWORD values in the range from +/-50 representing a two dimensional array of size 5 x 5. It should then display the array as a table (5 x 5) b

Write a program that can facilitate searching by indexing text files according to words. In this task, you are given a large text file, sample.txt, which you will need to index the

1 Problem Description The task of the assignment is to build a book recommendation system for Auer Libraries. The system is to be implemented in Prolog and as the owners of t

program the following exercises using JAVA and JENA API: SPARQL endpoint to be queried: QUERY:">http://services.data.gov.uk/education/sparql QUERY: What are the school’s names th

write a program to sort the file sequential order and store on magnetic tape and print sorted tape as the output of the program.

The Lost Bay Software Coop purchased EnviroMeasurements, a small startup with a product, GreenStation, that measures pollen count and air quality. The company has ventured

1-Create ir3.py based on ir2.py 2-Repeatedly prompt the user for a query (if they enter "q", then quit) 3-Find the terms in the query, and calculate the appropriate weight fo