Home Contents Index Summary Previous Next

3.27 Set Manipulation

is_set(+Set)
Succeeds if Set is a proper list (see proper_list/1) without duplicates.

list_to_set(+List, -Set)
Unifies Set with a list holding the same elements as List in the same order. If list contains duplicates, only the first is retained. See also sort/2. Example:


?- list_to_set([a,b,a], X)

X = [a,b]

intersection(+Set1, +Set2, -Set3)
Succeeds if Set3 unifies with the intersection of Set1 and Set2. Set1 and Set2 are lists without duplicates. They need not be ordered.

subtract(+Set, +Delete, -Result)
Delete all elements of set `Delete' from `Set' and unify the resulting set with `Result'.

union(+Set1, +Set2, -Set3)
Succeeds if Set3 unifies with the union of Set1 and Set2. Set1 and Set2 are lists without duplicates. They need not be ordered.

subset(+Subset, +Set)
Succeeds if all elements of Subset are elements of Set as well.

merge_set(+Set1, +Set2, -Set3)
Set1 and Set2 are lists without duplicates, sorted to the standard order of terms. Set3 is unified with an ordered list without duplicates holding the union of the elements of Set1 and Set2.