Prolog list of atoms

How to convert this

fact( [a,b,c], [d,e,f], ..., [p, q, r] )

to the list of these items?

Result:

[[a,b,c], [d,e,f], ..., [p, q, r]]
+3
source share
2 answers
list_fact_args(Fact,List) :- Fact =.. [fact|List].

=..- a convenient predicate that converts the predicate on the left to a list with the name of the predicate as the first member and its arguments as the last members. Or the list to the right of the predicate to the left. This factmeans that it lists only predicates with the name "fact".

+3
source

Get your Prolog tutorial or tutorial and look up = .. / 2.

0
source

All Articles