infix Z

Documentation for infix Z assembled from the following types:

language documentation Operators

From Operators

(Operators) infix Z

sub infix:<Z>(**@lists --> Seq:Dis assoc<chain>

The Zip operator interleaves the lists passed to Z like a zipper, taking index-corresponding elements from each operand. The returned Seq contains nested lists, each with a value from every operand in the chain. If one of the operands runs out of elements prematurely, the zip operator will stop.

say (12 Z <a b c> Z <+ ->).perl;
# OUTPUT: «((1, "a", "+"), (2, "b", "-")).Seq␤» 
for <a b c> Z <1 2 3 4> -> [$l$r{
    say "$l:$r"
}
# OUTPUT: «a:1␤b:2␤c:3␤» 

The Z operator also exists as a metaoperator, in which case the inner lists are replaced by the value from applying the operator to the list:

say 100200 Z+ 4223;             # OUTPUT: «(142 223)␤» 
say 1..3 Z~ <a b c> Z~ 'x' xx 3;    # OUTPUT: «(1ax 2bx 3cx)␤»