[ Reference Manual | Alphabetic Index ]

library(ordset)

Ordered set manipulation utilities   [more]

Predicates

is_ordset(?Term)
Checks whether term is an ordered set in the sense of lib(ordset)
list_to_ord_set(+List, -Set)
Converts a list to a set
ord_add_element(+Set1, +Element, -Set2)
Adds an element to a set
ord_compare(-Rel, +Set1, +Set2)
Rel is the ordering relationship between Set1 and Set2
ord_del_element(+Set, ?Term, -Remainder)
Remainder is the set Set without the element Term
ord_disjoint(+Set1, +Set2)
Checks whether two sets are disjoint
ord_disjoint_union(+Set1, +Set2, -Union)
Computes the union of Set1 and Set2 when they are disjoint
ord_insert(+Set1, +Element, -Set2)
Adds an element to a set
ord_intersect(+Set1, +Set2)
Checks whether two sets have a non-empty intersection
ord_intersect(+Set1, +Set2, -Intersection)
Computes the intersection of two sets
ord_intersection(+Sets, -Intersection)
Computes the intersection of all sets in Sets
ord_intersection(+Set1, +Set2, -Intersection)
Computes the intersection of two sets
ord_intersection(+Set1, +Set2, -Intersection, -Only1, -Only2)
Computes the intersection and the differences of two sets
ord_memberchk(?Term, +Set)
Checks whether Term is a member of Set
ord_nonmember(?Term, +Set)
Term is not a member of Set
ord_proper_subset(+Set1, +Set2)
Checks whether Set1 is a proper subset of Set2
ord_proper_superset(+Set1, +Set2)
Checks whether Set1 is a proper superset of Set2
ord_selectchk(?Term, +Set, -Remainder)
Set contains Term, and Remainder is the set Set without Term
ord_seteq(+Set1, +Set2)
Compares two sets for identity
ord_subset(+Set1, +Set2)
Checks whether Set1 is a subset of Set2
ord_subtract(+Set1, +Set2, -Difference)
Subtracts Set2 from Set1
ord_superset(+Set1, +Set2)
Checks whether Set1 is a superset of Set2
ord_symdiff(+Set1, +Set2, -Difference)
Computes the symmetric difference of Set1 and Set2
ord_union(+Sets, -Union)
Computes the union of all sets in Sets
ord_union(+Set1, +Set2, -Union)
Computes the union of Set1 and Set2
ord_union(+Set1, +Set2, -Union, -New)
Computes the union and difference of Set2 and Set1

Description

In this module, sets are represented by ordered lists with no duplicates. Thus the set {c,r,a,f,t} would be [a,c,f,r,t]. The ordering is defined by the @< family of term comparison predicates, which is the ordering used by sort/2 and setof/3.

The benefit of the ordered representation is that the elementary set operations can be done in time proportional to the Sum of the argument sizes rather than their Product. Some of the unordered set routines, such as member/2, length/2, select/3 can be used unchanged.

The implementation allows nonground set elements. The only problem with this is that a set can lose its set property as a result of variable bindings: unifications can create duplicates or change the element's position in the term order. The set can be repaired by applying list_to_ord_set/2 again, i.e. re-sorting it.

Note that the predicates of this library do no error checking. When called with the wrong argument types or modes, the result is undefined.

About


Generated from ordset.eci on 2022-09-03 14:26