Usage:
findall(X, Goal, Xlist)
Here X can be any term (usually variable) and G has to be an atomic goal (usually including X ). After the execution of this predicate in Xlist will be a list of the values for X in all successes of Goal . The difference between of and findall predicates is that the first one ( of ) succeeds as many times as Goal succeeds and every time it returns one value for X . The second one ( findall ) succeeds exactly once and returns in Xlist the list of all values for X . The length of this list is equal to the number of the successes of Goal (and also of of ).
Example:
?- findall(X, p(X), Xlist), write(Xlist).
p(a).
p(b).
p(c).