Operations on sets

Factor handbook » The language » Collections » Sets

Factor handbook » The language » Collections » Sets

Prev: | set? ( object -- ? ) |

Next: | Set implementations |

To test if an object is a member of a set:

All sets can be represented as a sequence, without duplicates, of their members:

To get the number of elements in a set:

Sets can have members added or removed destructively:

To test if a set is the empty set:

Basic mathematical operations, which any type of set may override for efficiency:

Mathematical predicates on sets, which may be overridden for efficiency:

Operations on groups of sets:

An optional generic word for creating sets of the same class as a given set:

An optional generic word for creating a set with a fast lookup operation, if the set itself has a slow lookup operation:

For set types that allow duplicates, like sequence sets, some additional words test for duplication:

Utilities for sets and sequences:

in? ( elt set -- ? )

All sets can be represented as a sequence, without duplicates, of their members:

members ( set -- seq )

To get the number of elements in a set:

cardinality ( set -- n )

Sets can have members added or removed destructively:

adjoin ( elt set -- )

delete ( elt set -- )

clear-set ( set -- )

union! ( set1 set2 -- set1 )

diff! ( set1 set2 -- set1 )

intersect! ( set1 set2 -- set1 )

To test if a set is the empty set:

null? ( set -- ? )

Basic mathematical operations, which any type of set may override for efficiency:

diff ( set1 set2 -- set )

intersect ( set1 set2 -- set )

union ( set1 set2 -- set )

Mathematical predicates on sets, which may be overridden for efficiency:

intersects? ( set1 set2 -- ? )

subset? ( set1 set2 -- ? )

set= ( set1 set2 -- ? )

Operations on groups of sets:

union-all ( sets -- set/f )

intersect-all ( sets -- set/f )

An optional generic word for creating sets of the same class as a given set:

set-like ( set exemplar -- set' )

An optional generic word for creating a set with a fast lookup operation, if the set itself has a slow lookup operation:

fast-set ( set -- set' )

For set types that allow duplicates, like sequence sets, some additional words test for duplication:

all-unique? ( set -- ? )

duplicates ( set -- seq )

Utilities for sets and sequences:

within ( seq set -- subseq )

without ( seq set -- subseq )

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.100 x86.64 (2240, heads/master-b90c89f82e, Sep 26 2023 19:59:25)