Set-theoretic operations on assocs
Factor handbook » The language » Collections » Associative mapping operations

Prev:Associative mapping combinators
Next:Associative mapping conversions


It is often useful to use the keys of an associative mapping as a set, exploiting the constant or logarithmic lookup time of most implementations (Association lists being a notable exception).

Set-theoretic operations:
assoc-subset? ( assoc1 assoc2 -- ? )

assoc-intersect ( assoc1 assoc2 -- intersection )

assoc-union ( assoc1 assoc2 -- union )

assoc-diff ( assoc1 assoc2 -- diff )

substitute ( seq assoc -- newseq )

extract-keys ( seq assoc -- subassoc )


Destructive operations:
assoc-union! ( assoc1 assoc2 -- assoc1 )

assoc-diff! ( assoc1 assoc2 -- assoc1 )


See also
key?, assoc-any?, assoc-all?, Sets