6.9 KiB
SRFI 113 - Sets and bags
Sets and bags (also known as multisets) are unordered collections that can contain any Scheme object. Sets enforce the constraint that no two elements can be the same in the sense of the set's associated equality predicate; bags do not.
See the SRFI document for more information.
Index
-
Constructors:
set
set-unfold
bag
bag-unfold
-
Predicates:
set?
set-contains?
set-empty?
set-disjoint?
bag?
bag-contains?
bag-empty?
bag-disjoint?
-
Accessors:
set-member
set-element-comparator
bag-member
bag-element-comparator
-
Updaters:
set-adjoin
set-adjoin!
set-replace
set-replace!
set-delete
set-delete!
set-delete-all
set-delete-all!
set-search!
bag-adjoin
bag-adjoin!
bag-replace
bag-replace!
bag-delete
bag-delete!
bag-delete-all
bag-delete-all!
bag-search!
-
The whole set:
set-size
set-find
set-count
set-any?
set-every?
bag-size
bag-find
bag-count
bag-any?
bag-every?
-
Mapping and folding:
set-map
set-for-each
set-fold
set-filter
set-filter!
set-remove
set-remove!
set-partition
set-partition!
bag-map
bag-for-each
bag-fold
bag-filter
bag-filter!
bag-remove
bag-remove!
bag-partition
bag-partition!
-
Copying and conversion:
set-copy
set->list
list->set
list->set!
bag-copy
bag->list
list->bag
list->bag!
-
Subsets:
set=?
set<?
set>?
set<=?
set>=?
bag=?
bag<?
bag>?
bag<=?
bag>=?
-
Set theory operations:
set-union
set-intersection
set-difference
set-xor
set-union!
set-intersection!
set-difference!
set-xor!
bag-union
bag-intersection
bag-difference
bag-xor
bag-union!
bag-intersection!
bag-difference!
bag-xor!
-
Additional bag procedures:
bag-sum
bag-sum!
bag-product
bag-product!
bag-unique-size
bag-element-count
bag-for-each-unique
bag-fold-unique
bag-increment!
bag-decrement!
bag->set
set->bag
set->bag!
bag->alist
alist->bag
-
Comparators:
set-comparator
bag-comparator
set
(set comparator element ...)
Returns a newly allocated empty set. The comparator argument is a SRFI 114 comparator, which is used to control and distinguish the elements of the set. The elements are used to initialize the set.
set-unfold
(set-unfold comparator stop? mapper successor seed)
Create a newly allocated set as if by set using comparator
. If the result of applying the predicate stop?
to seed
is true, return the set. Otherwise, apply the procedure mapper
to seed
. The value that mapper
returns is added to the set. Then get a new seed by applying the procedure successor
to seed
, and repeat this algorithm.
bag
bag-unfold
set?
(set? obj)
Returns #t
if obj
is a set, and #f
otherwise.
set-contains?
(set-contains? set element)
Returns #t
if element
is a member of set
and #f
otherwise.
set-empty?
(set-empty? set)
Returns #t
if set
has no elements and #f
otherwise.
set-disjoint?
(set-disjoint? set1 set2)
Returns #t
if set1
and set2
have no elements in common and #f
otherwise.
bag?
bag-contains?
bag-empty?
bag-disjoint?
set-member
(set-member set element default)
Returns the element of set
that is equal, in the sense of set's
equality predicate, to element
. If element
is not a member of set
, default
is returned.
set-element-comparator
(set-element-comparator set)
Returns the comparator used to compare the elements of set
.
bag-member
bag-element-comparator
#set-adjoin #set-adjoin! #set-replace #set-replace! #set-delete #set-delete! #set-delete-all #set-delete-all! #set-search! #bag-adjoin #bag-adjoin! #bag-replace #bag-replace! #bag-delete #bag-delete! #bag-delete-all #bag-delete-all! #bag-search!
#set-size #set-find #set-count #set-any? #set-every? #bag-size #bag-find #bag-count #bag-any? #bag-every?
#set-map #set-for-each #set-fold #set-filter #set-filter! #set-remove #set-remove! #set-partition #set-partition! #bag-map #bag-for-each #bag-fold #bag-filter #bag-remove #bag-partition #bag-filter! #bag-remove! #bag-partition!
#set-copy #set->list #list->set #list->set! #bag-copy #bag->list #list->bag #list->bag!
#set=? #set<? #set>? #set<=? #set>=? #bag=? #bag<? #bag>? #bag<=? #bag>=?
#set-union #set-intersection #set-difference #set-xor #set-union! #set-intersection! #set-difference! #set-xor! #bag-union #bag-intersection #bag-difference #bag-xor #bag-union! #bag-intersection! #bag-difference! #bag-xor!
#bag-sum #bag-sum! #bag-product #bag-product! #bag-unique-size #bag-element-count #bag-for-each-unique #bag-fold-unique #bag-increment! #bag-decrement! #bag->set #set->bag #set->bag! #bag->alist #alist->bag
#set-comparator #bag-comparator