creates a sorted list with all solutions of a goal for all instantiations of the free variables in that goal with duplicates removed....
Move to
Next Prev
Up Top
See also
bagof/3
findall/3
setof/3
IF Computer > MINERVA > Manual > Reference > Predicates > All Solutions > setof/3

setof/3

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

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

setof/3 unifies TermList for each different instantiation of the free variables in Goal with a sorted list of all instantiations of Term where Goal is a solution of Term. Duplicates will not be part of the list.
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).

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

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

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

Element = _1 What = floor List = [tile]

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

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

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

no

Standard

This predicate is part of the ISO-Prolog Standard.

See also

bagof/3, findall/3.

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Language
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/setof/home_en.html
published 2008/6/30 update 1998/8/5 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS