# Module sets

This module provides unordered sets. The unordered sets are
represented by lists [x1, .., xn]. The lists need not to be
ordered or duplicate free. But the provided operations do not
necessarily preserve duplicates.

Examples:

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

X = [3,1,2,4,5]

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

X = [1,5,2,3,4]

The realization uses a membership check based on (==)/2. As a
result the predicates are safe to be used with non-ground terms.
On the other hand, since this comparison is not arithmetical, 1
and 1.0 are for example considered different.

The following unordered sets predicates are provided:

**contains(E, S):**
- The predicate succeeds when the set S contains the element E.
**remove(E, S, T):**
- The predicate succeeds when the set S contains the element E
and T is the set without the element.
**difference(S1, S2, S3):**
- The predicate succeeds when S3 unifies with the difference of
S1 by S2.
**intersection(S1, S2, S3):**
- The predicate succeeds when S3 unifies with the intersection
of S1 and S2.
**union(S1, S2, S3):**
- The predicate succeeds when S3 unifies with the union of S1
and S2.
**subset(S1, S2):**
- The predicate succeeds when S1 is a subset of S2.
**permutation(S1, S2):**
- The predicate succeeds when S1 is a permutation of S2.

## Kommentare