% From the book % PROLOG PROGRAMMING IN DEPTH % by Michael A. Covington, Donald Nute, and Andre Vellino % (Prentice Hall, 1997). % Copyright 1997 Prentice-Hall, Inc. % For educational use only % File FINDALL.PL % Some examples of using findall, setof, and bagof % findall(V,Goal,L) :- bagof(V,Goal^Goal,L). % needed in some Prologs where findall is not built in father(michael,cathy). father(charles_gordon,michael). father(jim,melody). test1 :- findall(X,father(X,_),L), write(L), nl. test2 :- findall(X,father(_,X),L), write(L), nl. test3 :- findall(f(X),father(X,_),L), write(L), nl. test4 :- bagof(X,father(X,_),L), write(L), nl. test5 :- bagof(X,Y^father(X,Y),L), write(L), nl. test6 :- setof(X,Y^father(X,Y),L), write(L), nl.