Ordered sets are lists with unique elements sorted to the standard
order of terms (see sort/2).
Exploiting ordering, many of the set operations can be expressed in
order N rather than N^2 when dealing with unordered sets that
may contain duplicates. The
library(ordsets) is available
in a number of Prolog implementations. Our predicates are designed to be
compatible with common practice in the Prolog community. The
implementation is incomplete and relies partly on
an older ordered set library distributed with SWI-Prolog. New
applications are advices to use
Some of these predicates match directly to corresponding list
operations. It is adviced to use the versions from this library to make
clear you are operating on ordered sets.
True if Set is an empty ordered set. Set unifies
with the empty list.
Convert a List to an ordered set. Same as sort/2.
Add an element to an ordered set. NewSet is the same as
Set if Element is already part of Set.
Delete Element from Set. Succeeds without changing Set
if Set does not contain Element.
True if the intersection of Set1 and Set2 is
True if Intersection is the intersection of Set1
True if Set1 and Set2 have no common element.
True if Remaining contains the elements of Set
that are not in set Delete.
True if Union contains all elements from Set1 and Set2
+Set2, -Union, -New)
Defined as if
ord_union(Set1, Set2, Union),
ord_subtract(Set2, Set1, New).
True if all elements of Sub are in Super.
True if Element appears in Set. Does not
backtrack. Same as memberchk/2.