IF Computer > MINERVA > Manual > Reference > Predicates > All Solutions > findall/3

findall/3

MINERVA
ifcomputer logo
f
Expert Services on the Web

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.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/all_solutions/findall/print_en.html
published 2008/10/13 update 1998/8/5 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS