# set

A set is a collection which is unordered and can only contain things. Each thing will only exists once in a collection.

### Functions

Function Description
clear Remove all things from a set.
copy Copy a set (same as dup unless a non-zero deep argument is used).
dup Duplicate a set.
each Iterate over all items in a set.
every Check if all things pass a given test.
filter Return a new `set` with things that pass a given test.
find Return the first `thing` which passes a given test.
has Test if a set contains a given thing.
len Return the length of a set.
map Return a list with the results of calling a provided closure on every thing.
map_id Return a `list` with the Ids for all the things in the original set.
map_wrap Return a `list` with the Ids for all the things in the original set.
one Return one thing from the set.
reduce Execute a reducer function on each thing, resulting in a single output value.
remove Remove things from a set. Accepts one or more things to remove or a closure to be used as a test. The removed things are returned in a list.
restriction Return the restriction of the set or `nil` when the set is not restricted.
some Check if at least one thing passes a given test.

### Operators

Operation Description
`|` (union) Set with things from both `a` and `b`.
`&` (intersection) Set with things common to `a` and `b`.
`-` (difference) Set with things in `a` but not in `b`.
`^` (symmetric difference) Set with things in either `a` or `b` but not both.

Example set operators

``````anna = {};
cato = {};
iris = {};

a = set(cato, iris);
b = set(cato, anna);

assert (a | b == set(anna, cato, iris));    // Union
assert (a & b == set(cato));                // Intersection
assert (a - b == set(iris));                // Difference
assert (a ^ b == set(anna, iris));          // Symmetric difference
``````
Function Description
set Create a new empty set or convert a list to a new set.