| creates a list with all solutions of a goal according to a given pattern.
findall(+Term, +Goal, ?TermList)
findall/3 unifies TermList with a list with as many
instantiations of Term as Goal has solutions of Term.
If Goal does not succeed then TermList will be unified with
the emtpy list.
Arguments
Term term
Goal goal
TermList list
Examples
part_of(house, window).
part_of(house, door).
part_of(house, room).
part_of(room, table).
part_of(room, floor).
part_of(floor, tile).
contains(X, Y) :- part_of(X, Y).
contains(X, Y) :- part_of(X, Z), contains(Z, Y).
?- findall(Element, contains(What, Element), List).
Element = _1
What = _2
List = [window,door,room,table,floor,tile,table,floor,tile,tile]
?- setof(Element, contains(house, truck), List)
Element = _1
What = _2
List = []
Standard
This predicate is part of the ISO-Prolog Standard.
See also
bagof/3 ,
setof/3 ,
collect/3.
|