(lispkit set)
Last updated
Last updated
Library (lispkit set)
provides a generic implementation for sets of objects. Its API design is compatible to the R6RS-style API of library (lispkit hashtable)
.
A set is a data structure for representing collections of objects. Any object can be used as element, provided a hash function and a suitable equivalence function is available. A hash function is a procedure that maps elements to exact integer objects. It is the programmer’s responsibility to ensure that the hash function is compatible with the equivalence function, which is a procedure that accepts two objects and returns true if they are equivalent and #f
otherwise. Standard sets for arbitrary objects based on the eq?
, eqv?
, and equal?
predicates are provided.
set-type-tag
Symbol representing the set
type. The type-for
procedure of library (lispkit type)
returns this symbol for all set objects.
(make-eq-set)
Create a new empty set using eq?
as equivalence function.
(make-eqv-set)
Create a new empty set using eqv?
as equivalence function.
(make-equal-set)
Create a new empty set using equal?
as equivalence function.
(make-set hash equiv) (make-set hash equiv k)
Create a new empty set using the given hash function hash and equivalence function equiv. An initial capacity k can be provided optionally.
(eq-set element ...)
Create a new set using eq?
as equivalence function. Initialize it with the values element ... .
(eqv-set element ...)
Create a new set using eqv?
as equivalence function. Initialize it with the values element ... .
Create a new set using equal?
as equivalence function. Initialize it with the values element ... .
Returns the equivalence function used by set s.
Returns the hash function used by set s.
Returns #t
if set s is mutable.
Returns #t
if obj is a set.
Returns #t
if obj is an empty set.
Returns #t
if set s1 and set s2 are using the same equivalence function and contain the same elements.
Returns #t
if set s1 and set s2 are disjoint sets.
Returns #t
if set s1 is a subset of set s2.
Returns #t
if set s1 is a proper subset of set s2, i.e. s1 is a subset of s2 and s1 is not equivalent to s2.
Returns #
if set s contains element.
Returns true if there is at least one element in set s for which procedure proc returns true (i.e. not #f
).
Returns true if procedure proc returns true (i.e. not #f
) for all elements of set s.
Returns the number of elements in set s.
Returns the elements of set s as a vector.
Copies set s creating an immutable copy if mutable
is set to #f
or if mutable
is not provided.
Applies procedure proc to all elements of set s in an undefined order.
Creates a new set containing the elements of set s for which the procedure pred returns true.
Creates a new set containing the union of s with s1 ....
Creates a new set containing the intersection of s with s1 ....
Creates a new set containing the difference of s
and the sets in s1 ... .
Returns the elements of set s as a list.
Creates a new set using the equivalence function eq?
from the values in list elements.
Creates a new set using the equivalence function eqv?
from the values in list elements.
Creates a new set using the equivalence function equal?
from the values in list elements.
Adds element ... to the set s.
Deletes element ... from the set s.
Clears set s and reserves a capacity of k elements if k is provided.
Adds the values of list elements to set s.
Removes all elements from set s for which procedure pred returns #f
.
Stores the union of set s and sets s1 ... in s.
Stores the intersection of set s and the sets s1 ... in s.
Stores the difference of set s and the sets s1 ... in s.
(equal-set element ...)
(set-equivalence-function s)
(set-hash-function s)
(set-mutable? s)
(set? obj)
(set-empty? obj)
(set=? s1 s2)
(disjoint? s1 s2)
(subset? s1 s2)
(proper-subset? s1 s2)
(set-contains? s element)
(set-any? s proc)
(set-every? s proc)
(set-size s)
(set-elements s)
(set-copy s) (set-copy s mutable)
(set-for-each s proc)
(set-filter s pred)
(set-union s s1 ...)
(set-intersection s s1 ...)
(set-difference s s1 ...)
(set->list s)
(list->eq-set elements)
(list->eqv-set elements)
(list->equal-set elements)
(set-adjoin! s element ...)
(set-delete! s element ...)
(set-clear! s) (set-clear! s k)
(list->set! s elements)
(set-filter! s pred)
(set-union! s s1 ...)
(set-intersection! s s1 ...)
(set-difference! s s1 ...)