Operators

Set operators

Full

Membership, union, intersection and subset over lists treated as sets.

Raku has set-theoretic infixes that treat their operands as sets. Each has a Unicode spelling (, , , ) and an ASCII equivalent written in parentheses — (elem), (|), (&), (<=).

Membership — (elem) #

say 2 (elem) (1, 2, 3);
say 9 (elem) (1, 2, 3);
Output
True
False

Union and intersection #

(|) is union, (&) is intersection; both return a Set.

say (1, 2, 3) (|) (3, 4);
say (1, 2, 3) (&) (2, 3, 4);
Output
Set(1 2 3 4)
Set(2 3)

Subset — (<=) #

(<=) tests whether the left set is contained in the right.

say (1, 2) (<=) (1, 2, 3);
Output
True

Notes #