Define a prolog predicate flatten, Programming Languages

Assignment Help:

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

 


Related Discussions:- Define a prolog predicate flatten

Optimal solution, what is the optimal solution for this problem? Max 1...

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

Write a prolog predicate has duplicates, Write a Prolog predicate has_dupli...

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,e,b,

Mobile application in android platform phones, Recent problems in finishing...

Recent problems in finishing implementation: This mobile application is built with Sencha Touch framework. Source code is attached in this zip package. The daily rest calc

C.., I am still waiting on a quote from you

I am still waiting on a quote from you

Need support in mobile app using angularjs and cordova, Need support in Mob...

Need support in Mobile app using AngularJS, Cordova (PhoneGap), Ionicframework We need an experienced front-end developer with a obsession for performance in mobile environment.

Html code to create a web page design , 1.  Develop HTML code to create a W...

1.  Develop HTML code to create a Web page with the red background and title "My First Page" in any other color. 2.  Develop an HTML document with details of your name, telephon

.net windows services, .NET Windows Services But Enthusiasm has an amazi...

.NET Windows Services But Enthusiasm has an amazing record of beginning overdue but finding up easily. This is real in situation of .NET too. Enthusiasm put their best men at

Write a shell script to calculate gross salary, Write a shell script  (W.A...

Write a shell script  (W.A.S.S) to calculate gross salary. Program # Write a shell script  (W.A.S.S) to calculate gross salary. echo "Enter any Basic Salary"     #echo is

JUnit test, hi, can you help me with testing java classes I have wrote usin...

hi, can you help me with testing java classes I have wrote using java and jsp and servlet in eclipse ? I want to use JUnit for testing

What is the purpose of a hashtable, Question: (a) How do you implement...

Question: (a) How do you implement the following in ASP.NET: (i) Server-side Comments (ii) Server-side Include Directives. (b) What is the purpose of a HashTable? (

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd