/set
Unordered hash set algebraic operations: union, intersection, difference, symmetric-difference, subset?, and superset?.
Functions & symbols#
Set#
Constructs a new empty Set or initializes a Set with the given items.
Any(use /set)
(let s (Set))
(put s "apple")contains?#
Returns `true` if `item` is present in `set` in O(1) average time.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Target Set |
item | Any | required | Element to check |
Any(set/contains? #{1 2 3} 2) ; -> truecount-of#
Returns the number of distinct elements in `set`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Set to measure |
Any(set/count-of #{1 2 3}) ; -> 3difference#
Returns a new `Set` of elements in `a` that are not in `b`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
a | Set | required | Source set |
b | Set | required | Set of elements to exclude |
Any(set/difference #{1 2 3} #{2}) ; -> #{1 3}intersection#
Returns a new `Set` containing elements present in both `a` and `b`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
a | Set | required | First set |
b | Set | required | Second set |
Any(set/intersection #{1 2 3} #{2 3 4}) ; -> #{2 3}into-iter#
Returns an iterator yielding elements of `set`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Input Set |
Any(set/into-iter #{1 2 3})put#
Inserts an element into the set.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Target set |
item | Any | required | Item to insert |
Anyremove#
Removes `item` from `set` in place, returning `true` if it was present.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Mutable Set |
item | Any | required | Element to delete |
Any(set/remove tags "draft")subset?#
Returns `true` if every element of `a` also belongs to `b`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
a | Set | required | Candidate subset |
b | Set | required | Candidate superset |
Any(set/subset? #{1 2} #{1 2 3}) ; -> trueunion#
Returns a new `Set` containing elements from either `a` or `b`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
a | Set | required | First set |
b | Set | required | Second set |
Any(set/union #{1 2} #{2 3}) ; -> #{1 2 3}values-of#
Returns an Array containing all elements in the set.
| Parameter | Type | Optional | Description |
|---|---|---|---|
set | Set | required | Set to extract values from |
Any