Next: Global variables and DataBase
Up: Obtaining More Solutions
Previous: bagof or setof
Q: setof(Child, Age ^ age(Child,Age), ChildList),
setof(Age, Child ^ age(Child,Age), AgeList).
A: ChildList = [ anne, pat, peter, tom ]
AgeList = [5, 7, 8]
- Not only is duplicate removed, but list is also sorted
- Possible to combine objects within a program in other ways
Q: setof(Age/Child, age(Child,Age), List)
A: List = [5/anne, 5/tom, 7/peter, 8/pat]
- bagof/3 is similar to setof/3 - and differs only in that the solution
list is not sorted and may contain duplicates
Omer F Rana
Thu Feb 20 20:05:17 GMT 1997