File "sets"

This module provides persistent sets. The predicates subtract/3, intersection/3, union/3 and symdiff/3 provide basic set operations. To work correctly they require ground lists.

Examples:
?- intersection([2,3],[1,2],X).
X = [2]

?- union([2,3],[1,2],X).
X = [3, 1, 2]

Further ground list based predicates are subset/2, disjoint/2 and equal/2. The implementations for the ground list based predicates might differ from other implementations since they do not simply fail or loop if the leading argument is not a ground list. Instead, they throw either an instantiation error or type error to provide more safety.

The following set predicates are provided:

subtract(S, T, R):
The predicate succeeds when R unifies with the subtract of S by T.
intersection(S, T, R):
The predicate succeeds when R unifies with the intersection of S and T.
union(S, T, R):
The predicate succeeds when R unifies with the union of S and T.
symdiff(S, T, R):
The predicate succeeds when R unifies with the symmetric subtract of S and T.
subset(S, T):
The predicate succeeds when S is a subset of T.
disjoint(S, T):
The predicate succeeds when S is disjoint to T.
equal(S, T):
The predicate succeeds when S is equal to T.

Kommentare