3.16 Sets
A set represents a set of distinct elements. For a given
set, elements are equivalent via equal?, eqv?, or
eq?. Two sets are equal? when they use the same
element-comparison procedure (equal?, eqv?, or
eq?) and have equivalent elements.
A set can be used as a single-valued sequence (see
Sequences). The elements of the set serve as elements
of the sequence. See also in-set.
Operations on sets that contain elements that are mutated are
unpredictable in much the same way that hash table operations are
unpredictable when keys are mutated.
Returns
#t if
v is a
set,
#f
otherwise.
Returns
#t if
set compares elements with
eqv?,
#f if it compares with
equal? or
eq?.
Returns
#t if
set compares elements with
eq?,
#f if it compares with
equal? or
eqv?.
Creates a set that uses
equal?,
eq?, or
eqv?, respectively, to compare elements. The given
vs are added to the set. The elements are added in the order
that they appear as
vs, so in the first two cases, an earlier
element that is
equal? or
eqv? but not
eq?
to a later element takes precedence over the later element.
Returns #t if set has no members, #f
otherwise.
Returns #t if v is in set, #f
otherwise.
Like operations on immutable hash tables, “constant
time” set operations actually require O(log N) time for a set
of size N.
Produces a set that includes v plus all elements of
set. This operation runs in constant time.
Produces a set that includes all elements of set except
v. This operation runs in constant time.
Produces a set that includes all elements of all given
sets,
which must all use the same equivalence predicate (
equal?,
eq?, or
eqv?). This operation runs in time
proportional to the total size of all given
sets except for
the largest.
Produces a set that includes only the elements in all of the given
sets, which must all use the same equivalence predicate
(
equal?,
eq?, or
eqv?). This operation
runs in time proportional to the total size of all given
sets except for the largest.
Produces a set that includes all elements the first
sets that
are not present in any of the other given
setss. All of the
given
sets must use the same equivalence predicate
(
equal?,
eq?, or
eqv?). This operation
runs in time proportional to the total size of all given
sets except the first one.
Returns
#t if every member of
set is in
set2,
#f otherwise. The
set and
set2 must use the same equivalence predicate
(
equal?,
eq?, or
eqv?). This operation
runs in time proportional to the size of
set.
Applies the procedure proc to each element in
set in an unspecified order, accumulating the results
into a list.
Applies proc to each element in set (for the
side-effects of proc) in an unspecified order.
Explicitly converts a set to a sequence for use with
for and
other forms.
(for/set (for-clause ...) body ...+) |
|
|
|
|
|
|