September 2017
Beginner
402 pages
9h 52m
English
The Z operator works like a zipper and creates a new array out of the given two arrays. The elements in the new array are picked up from the elements of the operands as the zipper connects its item.
The behavior of the Z operator can be clearly seen in the following example:
my @odd = 1, 3, 5, 7, 9;my @even = 2, 4, 6, 8, 10;my @all = @odd Z @even;say @all;
This program prints the following list which contains nested lists based on the elements from both the @odd and @even arrays:
[(1 2) (3 4) (5 6) (7 8) (9 10)]
If one of the array operands is of a different length, the result of the Z operator will contain as many elements as the shortest one contains.