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


Function Description
add Add things to 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.
reduce Execute a reducer function on each thing, resulting in a single output value.
remove Remove things from a set.
some Check if at least one thing passes a given test.


Operation Description
` ` (union)
& (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

Be careful using assignment operators on stored sets. Although set operations are processed very efficient, a change to a stored set requires an event. This event is still an assignment and will therefore contain the complete resulting set.
In practice this means that it is perfect to write something like set_a |= set_b, but avoid using a stored set like .set_a |= set_b.

Function Description
set Create a new empty set or convert a list to a new set.