Next: srfi sets-and-bags bag, Previous: srfi sets-and-bags subsets, Up: srfi sets-and-bags [Index]
Return a newly allocated set that is the union, intersection, asymmetric difference, or symmetric difference of the set arguments.
Asymmetric difference is extended to more than two sets by taking the difference between the first set and the union of the others. Symmetric difference is not extended beyond two sets. Elements in the result set are drawn from the first set in which they appear.
(import (vicare) (srfi :113) (srfi :114)) (let* ((S1 (set fixnum-comparator 1 2)) (S2 (set fixnum-comparator 2 3)) (S (set-difference S1 S2))) (set->list S #t)) ⇒ (1)
Like set-union!
, set-intersection!
,
set-difference!
, set-xor!
but they are allowed to mutate
set0 and return it.
Return a newly allocated bag that is the union, intersection, asymmetric difference, or symmetric difference of the bag arguments.
Asymmetric difference is extended to more than two bags by taking the difference between the first bag and the union of the others. Symmetric difference is not extended beyond two bags. Elements in the result bag are drawn from the first bag in which they appear.
The procedures behave as follows when both bags contain elements that are equal in the sense of the bags’ comparator:
bag-union
The number of equal elements in the result is the largest number of equal elements in any of the original bags.
bag-intersection
The number of equal elements in the result is the smallest number of equal elements in any of the original bags.
bag-difference
The number of equal elements in the result is the number of equal elements in the first bag, minus the number of elements in the other bags (but not less than zero).
bag-xor
The number of equal elements in the result is the absolute value of the difference between the number of equal elements in the first and second bags.
Like bag-union!
, bag-intersection!
,
bag-difference!
, bag-xor!
but they are allowed to mutate
bag0 and return it.
Next: srfi sets-and-bags bag, Previous: srfi sets-and-bags subsets, Up: srfi sets-and-bags [Index]