Sets represent an unordered collections of unique elements of atomic type. Sets are defined in next way:

const s1 := [:1, 2, 3:]             # set of ints
const s2 := [:"foo", "bar", "baz":] #set of strings

The empty set is defined as [::] and has no item type.

Supported types

Set can contain only atomic type except bool. Talking simple it can be only int, float or string.

Set operations

There are some operations that can be done with sets. They are conjunction, disjunction, subtraction and intersection.

Symbol Description
+ Elements from any set
* Only elements from both sets
/ Elements that are in left set but not in right


[:"foo", "baz":] + [:"baz", "bar":];  # will contain foo, baz, bar
[:"foo", "baz":] * [:"baz", "bar":];  # only baz
[:"foo", "baz":] / [:"baz":];         # only foo

Sets can be compared. Result of comparing is bool.

Symbol Description
= Sets are equal
<> Sets are not equal
< Right set is superset of the left
> Left set is superset if the right

Set is a superset of another set if it contains all it’s elements.


[:1, 2, 3:] < [:1, 2, 3, 4, 5:];  # true
[:1, 2, 3, 9:] > [:1, 2, 4:];     # false
[:1, 2, 3:] <> [:4, 5:];          # true
[::] = [::]                       # true

Sets do not contain item values so it is impossible to cast set to list or get set elements in some other way. The only possible operation is to check does set sontains some value. Therefore there is only one way to print set items: iterate throug all possible elements and check their persistence in set.