Mar 20, 2007 #1 djgloom Technical User Joined Mar 20, 2007 Messages 2 Location DE Hello! Could you help me with an advise: how to get elements into a list: el(a). el(b). el(c). ... so, that prolog answers: ? - list(L). L = [a, b, c, ...] No Thank you in advance!
Hello! Could you help me with an advise: how to get elements into a list: el(a). el(b). el(c). ... so, that prolog answers: ? - list(L). L = [a, b, c, ...] No Thank you in advance!
Mar 22, 2007 #2 surfbluedog Technical User Joined Dec 2, 2003 Messages 4 Location NZ You can achieve this using the inbuilt setof predicate like this: el(a). el(b). el(c). list(L):- setof(X, el(X), L). Upvote 0 Downvote
You can achieve this using the inbuilt setof predicate like this: el(a). el(b). el(c). list(L):- setof(X, el(X), L).
Mar 22, 2007 Thread starter #3 djgloom Technical User Joined Mar 20, 2007 Messages 2 Location DE Thanks a lot! There is also equivalent builtin predicate findall(X, el(X), List) Upvote 0 Downvote