creates a list with all solutions of a goal for all instantiations of...
Move to
=> <=
Darueber Spitze
See also
bagof/3
findall/3
setof/3
IF Computer > MINERVA > Manual > Reference > Predicates > All Solutions > bagof/3

bagof/3

creates a list with all solutions of a goal for all instantiations of the free variables in that goal.

bagof(+Term, +(Template ^ Goal), ?TermList)
bagof(+Term, +Goal, ?TermList)

bagof/3 unifies TermList for each different instantiation of the free variables in Goal with a list of all instantiations of Term where Goal is a solution of Term. Each variable, wich occurs in Goal and does not occur in Term or Template is called a free variable.

Arguments

Term                   term
Template               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).

?- bagof(Element, contains(What, Element), List).

Element = _1 What = house List = [window,door,room,table,floor,tile];

Element = _1 What = room List = [table,floor,tile];

Element = _1 What = floor List = [tile]

?- bagof(Element, What ^ contains(What, Element), List).

Element = _1 What = _2 List = [window,door,room,table,floor,tile,table,floor,tile,tile]

?- bagof(Element, contains(house, truck), List)

no

Standard

This predicate is part of the ISO-Prolog Standard.

See also

findall/3, setof/3

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Sprache
English
Japanese
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/all_solutions/bagof/home_de.html
published 2008/9/1 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
scroll to top managed with ubiCMS