Question: Write a predicate in Prolog cleanListDCG/3 which parses a list and returns a new list with the same numbers but all elements that are not

Write a predicate in Prolog cleanListDCG/3 which parses a list and returns a new list with the same numbers but all elements that are not a number removed. You must use only DCG notation. Your implementation of cleanListDCG/3 must work correctly when called from cleanList/2.

cleanList(L,LL) :- cleanListDCG(LL,L,[]),!.

Example: ?- cleanList([1,2,d,67,3.2,'CSI2120',foo,5],LL).

LL = [1, 2, 67, 3.2, 5].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!