Create a custom set type.
Sometimes it is necessary to define a custom data structure of some type, like a set. In this exercise you will define your own set. How it works internally doesn't matter, as long as it behaves like a set of unique elements.
raku has built-in set support.
Operators are available in mathematical notation (via Unicode) along with ASCII equivalents:
| Unicode | ASCII | Description |
|---|---|---|
∅ |
set() |
empty set |
∩ |
(&) |
intersection |
∪ |
(|) |
union |
∖ |
(-) |
set difference |
⊖ |
(^) |
set symmetric difference |
| Unicode | ASCII | Description |
|---|---|---|
≡ |
(==) |
are identical |
≢ |
!(==) |
not identical |
∈ |
(elem) |
is an element of |
∉ |
!(elem) |
is not an element of |
∋ |
(cont) |
contains |
∌ |
!(cont) |
does not contain |
⊆ |
(<=) |
is a subset or equal to |
⊈ |
!(<=) |
is not a subset or equal to |
⊂ |
(<) |
is a strict subset of |
⊄ |
!(<) |
is not a strict subset of |
⊇ |
(>=) |
is a superset or equal to |
⊉ |
!(>=) |
is not a superset or equal to |
⊃ |
(>) |
is a strict superset of |
⊅ |
!(>) |
is not a strict superset of |
Sign up to Exercism to learn and master Raku with 94 exercises, and real human mentoring, all for free.