September 2017
Beginner
402 pages
9h 52m
English
The cross meta-operator Xop takes two lists and applies the op operator to every possible combination of the elements of the lists.
The result of the operation is another list. Take a look at the following example with two lists of three numbers in each:
my @x = (1, 2, 3);my @y = (4, 5, 6);say @x X+ @y;
The code prints a list with six elements, each of which is the sum of two elements of @x and @y:
(5 6 7 6 7 8 7 8 9)
Let's use the string concatenation (~) and use the same @x and @y arrays in the X~ operation:
say @x X~ @y;
In this case, every pair of numbers is converted to a pair of strings, and then they are concatenated. You can see how the X meta-operator picks the elements of its operands:
(14 15 16 24 25 26 34 ...
Read now
Unlock full access