
Assuming the definitions for fact and color from the previous examples.
|(any '(?x is the factorial of 5) '(fact 5 ?x))|
|(120 IS THE FACTORIAL OF 5)
|
|(findall '(?x is a color) '(color ?x))|
|((RED IS A COLOR) (BLUE IS A COLOR)
(GREEN IS A COLOR))
|
|(findall '?y '(or (= ?y 5) (= ?y 5)))|
|(5 5)
|
|(findallset '?y '(or (= ?y 5) (= ?y 5)))
|
|(5)
FINDALL and FINDALLSET will hang if a goal expression generates an infinite solution set.
More powerful all solution predicates ( BAGOF and SETOF ) are available from within Common Prolog.
A different interface is available for predicates which will be called often from Lisp. The macro deflogfun may be used to generate normal Lisp functions that run with precompiled goals.