, , , . . , , . bagof, setof findall.
bagof (X, , 1)
L, X, , . , , X . , , :
age(peter, 1). agel ana, ). age(pat, 8). age (torn, 5).
5 :
7.
?- bagofI Child, age (Child, 5), List). List = [ ana, torn)
, , :
?- ba 1 oft Child, age f Child, Age!-, List).
Age = /
List = [ peter];
Age = 5
List = [ ann, torn];
Age = S
List = [ pat];
No
, . , bagof "", ; , . :
?- bagof (Child, Age (Child, Age), List). List = [ peter, ann, pat, torn]
"*■" xfy.
bagof (X, , L), bagof . X , L , .
setof bagof. setof{ X,?, L)
I, X, . L , , , . @<, , , :
s?-toiriChct'ild^ aChild,^r Ag <^.£t)' AgeList =* [ ChTspat, peter,t£ml
, , . , , , , Age/Child :
?- setof (Age/Child, age (Child, Age}, List! List = [ 8/arm, 5/tcm, 7/peter, 8/pat;
, bagof, findall. findall< , , L)
, . findall bagof , X, () , X. :
|
|
?- findall: Child, agef Child, Age), List). List = [ p>:;, ann, pat, tern]
X, ?, , findall, , L - [ ].
I. Prolog
f indall , , . , , . , . , , . , . = = : , . , , , , "bottom" ( , , , ). findall 7.3.