cyclone/docs/api/srfi/113.md
Justin Ethier e30a219ad9 WIP
2016-11-30 18:52:38 -05:00

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

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