NextPrevUpTopContentsIndex

A.6.2.1 Examples

Assuming the definitions for fact and color from the previous examples.

|(any '(?x is the factorial of 5) '(fact 5 ?x))

returns:

|
|(120 IS THE FACTORIAL OF 5)
|
|(findall '(?x is a color) '(color ?x))

returns:

|
|((RED IS A COLOR) (BLUE IS A COLOR) 
  (GREEN IS A COLOR))
|
|(findall '?y '(or (= ?y 5) (= ?y 5)))

returns:

|
|(5 5)
|
|(findallset '?y '(or (= ?y 5) (= ?y 5)))

returns:

|
|(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.


KnowledgeWorks and Prolog User Guide (Macintosh version) - 29 Feb 2008

NextPrevUpTopContentsIndex