**Author(s):** Lena Flood.

**Version:** 1.10#6 (2004/8/7, 21:46:39 CEST)

**Version of last change:** 1.9#239 (2003/12/22, 18:32:52 CET)

This module implements set operations. Sets are just ordered lists.

`sets`

)**Library usage:**`:- use_module(library(sets)).`

**Exports:****Other modules used:**

`sets`

)- PREDICATE:
**insert/3:** -
**Usage:**`insert(+Set1, +Element, -Set2)`

*Description:*It is true when`Set2`

is`Set1`

with`Element`

inserted in it, preserving the order.

- PREDICATE:
**ord_delete/3:** -
**Usage:**`ord_delete(+Set0, +X, -Set)`

*Description:*It succeeds if`Set`

is`Set0`

without element`X`

.

- PREDICATE:
**ord_member/2:** -
**Usage:**`ord_member(+X, +Set)`

*Description:*It succeeds if`X`

is member of`Set`

.

- PREDICATE:
**ord_test_member/3:** -
**Usage:**`ord_test_member(+Set, +X, -Result)`

*Description:*If`X`

is member of`Set`

then`Result`

=`yes`

. Otherwise`Result`

=`no`

.

- PREDICATE:
**ord_subtract/3:** -
**Usage:**`ord_subtract(+Set1, +Set2, ?Difference)`

*Description:*It is true when`Difference`

contains all and only the elements of`Set1`

which are not also in`Set2`

.

- PREDICATE:
**ord_intersection/3:** -
**Usage:**`ord_intersection(+Set1, +Set2, ?Intersection)`

*Description:*It is true when`Intersection`

is the ordered representation of`Set1`

and`Set2`

, provided that`Set1`

and`Set2`

are ordered lists.

- PREDICATE:
**ord_intersection_diff/4:** -
**Usage:**`ord_intersection_diff(+Set1, +Set2, -Intersect, -NotIntersect)`

*Description:*`Intersect`

contains those elements which are both in`Set1`

and`Set2`

, and`NotIntersect`

those which are in`Set1`

but not in`Set2`

.

- PREDICATE:
**ord_intersect/2:** -
**Usage:**`ord_intersect(+Xs, +Ys)`

*Description:*Succeeds when the two ordered lists have at least one element in common.

- PREDICATE:
**ord_subset/2:** -
**Usage:**`ord_subset(+Xs, +Ys)`

*Description:*Succeeds when every element of`Xs`

appears in`Ys`

.

- PREDICATE:
**ord_subset_diff/3:** -
**Usage:**`ord_subset_diff(+Set1, +Set2, -Difference)`

*Description:*It succeeds when every element of`Set1`

appears in`Set2`

and`Difference`

has the elements of`Set2`

which are not in`Set1`

.

- PREDICATE:
**ord_union/3:** -
**Usage:**`ord_union(+Set1, +Set2, ?Union)`

*Description:*It is true when`Union`

is the union of`Set1`

and`Set2`

. When some element occurs in both sets,`Union`

retains only one copy.

- PREDICATE:
**ord_union_diff/4:** -
**Usage:**`ord_union_diff(+Set1, +Set2, -Union, -Difference)`

*Description:*It succeeds when`Union`

is the union of`Set1`

and`Set2`

, and`Difference`

is`Set2`

set-minus`Set1`

.

- PREDICATE:
**ord_union_symdiff/4:** -
**Usage:**`ord_union_symdiff(+Set1, +Set2, -Union, -Diff)`

*Description:*It is true when Diff is the symmetric difference of Set1 and Set2, and Union is the union of Set1 and Set2.

- PREDICATE:
**ord_union_change/3:** -
**Usage:**`ord_union_change(+Set1, +Set2, -Union)`

*Description:*`Union`

is the union of`Set1`

and`Set2`

and`Union`

is different from`Set2`

.

- PREDICATE:
**merge/3:** -
**Usage:**`merge(+Set1, +Set2, ?Union)`

*Description:*See`ord_union/3`

.

- PREDICATE:
**ord_disjoint/2:** -
**Usage:**`ord_disjoint(+Set1, +Set2)`

*Description:*`Set1`

and`Set2`

have no element in common.

- PREDICATE:
**setproduct/3:** -
**Usage:**`setproduct(+Set1, +Set2, -Product)`

*Description:*`Product`

has all two element sets such that one element is in`Set1`

and the other in`set2`

, except that if the same element belongs to both, then the corresponding one element set is in`Product`

.

Go to the first, previous, next, last section, table of contents.