Tracks
/
Raku
Raku
/
Exercises
/
Custom Set
Custom Set

Custom Set

Easy

Instructions

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.

Set Operators

raku has built-in set support.

Operators are available in mathematical notation (via Unicode) along with ASCII equivalents:

Set context

Unicode ASCII Description
∅ set() empty set
∩ (&) intersection
∪ (|) union
∖ (-) set difference
⊖ (^) set symmetric difference

Boolean context

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
Edit via GitHub The link opens in a new window or tab
Raku Exercism

Ready to start Custom Set?

Sign up to Exercism to learn and master Raku with 94 exercises, and real human mentoring, all for free.