Node:SRFI-1 Set Operations,
Previous:SRFI-1 Association Lists,
Up:SRFI-1
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.
|
lset-adjoin = list elt1 ...
|
Scheme Procedure |
lset-adjoin! = list elt1 ...
|
Scheme Procedure |
Add all elts to the list list, suppressing duplicates and
return the resulting list. lset-adjoin! is allowed, but not
required to modify its first argument. = is used for testing
element equality.
|
lset-union = list1 ...
|
Scheme Procedure |
lset-union! = 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.
lset-union! is allowed, but not required to modify its first
argument. = is used for testing element equality.
|
lset-intersection = list1 list2 ...
|
Scheme Procedure |
lset-intersection! = 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.
lset-intersection! is allowed, but not required to modify its
first argument. = is used for testing element equality.
|
lset-difference = list1 list2 ...
|
Scheme Procedure |
lset-difference! = 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. lset-difference! is allowed, but
not required to modify its first argument. = is used for testing
element equality.
|
lset-xor = list1 ...
|
Scheme Procedure |
lset-xor! = 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. lset-xor! is allowed, but
not required to modify its first argument. = is used for testing
element equality.
|
lset-diff+intersection = list1 list2 ...
|
Scheme Procedure |
lset-diff+intersection! = list1 list2 ...
|
Scheme Procedure |
Return two values, the difference and the intersection of the argument
list sets. This works like a combination of lset-difference and
lset-intersection , but is more efficient.
lset-diff+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).
|