![]() |
YAP 7.1.0
|
When there are several solutions to a goal, if the user wants to collect all the solutions he may be led to use the data base, because backtracking will forget previous solutions. More...
When there are several solutions to a goal, if the user wants to collect all the solutions he may be led to use the data base, because backtracking will forget previous solutions.
YAP allows the programmer to choose from several system predicates instead of writing his own routines findall/3 gives you the fastest, but crudest solution The other built-in predicates post-process the result of the query in several different ways:
class findall/3 |
findall( T,+ G,- L)
defined in the ISO standard
findall/3 is a simplified version of bagof which has an implicit existential quantifier on every variable
Unifies L with a list that contains all the instantiations of the term T satisfying the goal G
With the following program:
the answer to the query
would be:
class findall/4 |
findall( ?Key, +Goal, +InitialSolutions, -Solutions )
Similar to findall/3 , but appends all answers to list L0 Useful, if some answers have already been found
class setof/3 |
setof( X,+ P,- B)
defined in the ISO standard
Similar to bagof( _T_, _G_, _L_)
but sorts list L and keeping only one copy of each element Again, assuming the same clauses as in the examples above, the reply to the query
would be:
class bagof/3 |
bagof( T,+ G,- L)
defined in the ISO standard
For each set of possible instances of the free variables occurring in G but not in T, generates the list L of the instances of T satisfying G Again, assuming the same clauses as in the examples above, the reply to the query
And this is bagof/3
Either we have excess of variables and we need to find the solutions for each instantiation of these variables