Mar 20, 2007 #1 djgloom Technical User Mar 20, 2007 2 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 Dec 2, 2003 4 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 Mar 20, 2007 2 DE Thanks a lot! There is also equivalent builtin predicate findall(X, el(X), List) Upvote 0 Downvote