Yet Another Perl 6 Operator: Zip
by Adriano Ferreira
Perl 6 has an operator
Z, named zip, to interleave elements of two or more arrays.
my @a = 1,2 Z -1,-2; # (1,-1),(2,-2)
The zip is one of the list generating operators that gives the language some flavor of functional programming. This gets further as the usual semantics for lists is to get lazy generation, which means easy/efficient handling of large lists (and also the extreme case of infinite lists).
Very, very strange feature. In perl 5 I can use
map [ $a[$_], $b[$_] ], 0..max(scalar @a, scalar @b)-1
|In Perl 5 you can use &zip from List::MoreUtils as well and the related iterators: &pairwise, &each_array, &each_arrayref. In Perl 6, the zip operator is enough to get all the behavior of these. You said the operation is not frequent, but I think it is so due to the lack of built-in support for it. Time will tell.|