Next: , Previous: , Up: srfi sets-and-bags   [Index]


2.37.8 Copying and conversion

Function: set-copy set
Function: bag-copy bag

Return a newly allocated set or bag containing the elements of set or bag and using the same comparator.

Function: set->list set
Function: bag->list bag
Function: set->list set compar
Function: bag->list bag compar

Return a newly allocated list containing the members of set or bag in unspecified order.

As Vicare extension, if the optional argument compar is present:

Usage examples:

(import (vicare) (srfi :113) (srfi :114))

(list-sort < (set->list (set fixnum-comparator 1 2 3)))
⇒ (1 2 3)

(set->list (set fixnum-comparator 1 2 3) #t)
⇒ (1 2 3)

(set->list (set fixnum-comparator 1 2 3) fx<?)
⇒ (1 2 3)

(set->list (set fixnum-comparator 1 2 3) fx>?)
⇒ (3 2 1)

;;;

(list-sort < (bag->list (bag fixnum-comparator 1 2 2 3)))
⇒ (1 2 2 3)

(bag->list (bag fixnum-comparator 1 2 2 3) #t)
⇒ (1 2 2 3)

(bag->list (bag fixnum-comparator 1 2 2 3) fx<?)
⇒ (1 2 2 3)

(bag->list (bag fixnum-comparator 1 2 2 3) fx>?)
⇒ (3 2 2 1)
Function: list->set comparator list
Function: list->bag comparator list

Return a newly allocated set or bag, created as if by set or bag using comparator, that contains the elements of list. When building a set: duplicate elements (in the sense of the equality predicate) are omitted.

Function: list->set! set list
Function: list->bag! bag list

Return a set or bag that contains the elements of both set or bag and list, using the comparator of set or bag. The functions are permitted to mutate set or bag and return it. When building a set: duplicate elements (in the sense of the equality predicate) are omitted.


Next: , Previous: , Up: srfi sets-and-bags   [Index]