PLOGHELP FAST_BAGOF Jonathan Laventhol, 15 July 1983
Revised by Kathryn Seifert October 1986
Produces a bag of patterns which will satisfy a given goal
?- fast_bagof(Pattern, Goal, Bag).
Keywords: goal, goal satisfaction
A builtin predicate for getting a list of the solutions to a goal. It
is like 'bagof' (see PLOGHELP * BAGOF), except that you cannot backtrack
on solutions where variables appearing in Goal do not occur in Pattern.
In a query of the form:
?- fast_bagof(Ma, parents(Pa, Ma, Child), B).
'fast_bagof' will treat the meaning of this query as "B is the bag of
all Mas such that Pa and Ma are the father and mother of Child for ANY
Pa and Child".
For example, given the database of facts:
parents(frances, richard, kathy).
parents(elsie, mel, jon).
parents(joanne, kenny, frank).
we can call 'fast_bagof' as above with the following results:
?- fast_bagof(Ma, parents(Ma, Pa, Child), B).
Ma = _1
Pa = _2
Child = _3
B = [joanne, elsie, frances]
? ;
no
Compare with * BAGOF, * SETOF, and * FAST_SETOF.
-- RELATED DOCUMENTATION ----------------------------------------------
PLOGHELP * BAGOF
Produces a bag of patterns which will satisfy a given goal
PLOGHELP * SETOF
Produces a set of patterns which will satisfy a given goal
PLOGHELP * FAST_SETOF
Fast version of 'setof'
PLOGHELP * FINDALL
Library program to find all the terms which satisfy a given predicate