infix Z
1 | language documentation Operators |
1.1 | (Operators) infix Z |
Documentation for infix Z
assembled from the following types:
language documentation Operators
From Operators
(Operators) infix Z
sub infix:<Z>(** --> Seq) is 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 (1, 2 Z <a b c> Z <+ ->).perl;# OUTPUT: «((1, "a", "+"), (2, "b", "-")).Seq»for <a b c> Z <1 2 3 4> -> [, ]# OUTPUT: «a:1b:2c: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 100, 200 Z+ 42, 23; # OUTPUT: «(142 223)»say 1..3 Z~ <a b c> Z~ 'x' xx 3; # OUTPUT: «(1ax 2bx 3cx)»