Node:SRFI1 Set Operations,
Previous:SRFI1 Association Lists,
Up:SRFI1
39.3.10 Set Operations on Lists
Lists can be used for representing sets of objects. The procedures
documented in this section can be used for such set representations.
Man combining several sets or adding elements, they make sure that no
object is contained more than once in a given list. Please note that
lists are not a too efficient implementation method for sets, so if
you need high performance, you should think about implementing a
custom data structure for representing sets, such as trees, bitsets,
hash tables or something similar.
All these procedures accept an equality predicate as the first
argument. This predicate is used for testing the objects in the list
sets for sameness.
lset<= = list1 ...

Scheme Procedure 
Return #t if every listi is a subset of listi+1,
otherwise return #f . Returns #t if called with less
than two arguments. = is used for testing element equality.

lset= = list1 list2 ...

Scheme Procedure 
Return #t if all argument lists are equal. = is used for
testing element equality.

lsetadjoin = list elt1 ...

Scheme Procedure 
lsetadjoin! = list elt1 ...

Scheme Procedure 
Add all elts to the list list, suppressing duplicates and
return the resulting list. lsetadjoin! is allowed, but not
required to modify its first argument. = is used for testing
element equality.

lsetunion = list1 ...

Scheme Procedure 
lsetunion! = list1 ...

Scheme Procedure 
Return the union of all argument list sets. The union is the set of
all elements which appear in any of the argument sets.
lsetunion! is allowed, but not required to modify its first
argument. = is used for testing element equality.

lsetintersection = list1 list2 ...

Scheme Procedure 
lsetintersection! = list1 list2 ...

Scheme Procedure 
Return the intersection of all argument list sets. The intersection
is the set containing all elements which appear in all argument sets.
lsetintersection! is allowed, but not required to modify its
first argument. = is used for testing element equality.

lsetdifference = list1 list2 ...

Scheme Procedure 
lsetdifference! = list1 list2 ...

Scheme Procedure 
Return the difference of all argument list sets. The difference is
the the set containing all elements of the first list which do not
appear in the other lists. lsetdifference! is allowed, but
not required to modify its first argument. = is used for testing
element equality.

lsetxor = list1 ...

Scheme Procedure 
lsetxor! = list1 ...

Scheme Procedure 
Return the set containing all elements which appear in the first
argument list set, but not in the second; or, more generally: which
appear in an odd number of sets. lsetxor! is allowed, but
not required to modify its first argument. = is used for testing
element equality.

lsetdiff+intersection = list1 list2 ...

Scheme Procedure 
lsetdiff+intersection! = list1 list2 ...

Scheme Procedure 
Return two values, the difference and the intersection of the argument
list sets. This works like a combination of lsetdifference and
lsetintersection , but is more efficient.
lsetdiff+intersection! is allowed, but not required to modify
its first argument. = is used for testing element equality. You
have to use some means to deal with the multiple values these
procedures return (see Multiple Values).
