On 10/21/05, Mark Reed <[EMAIL PROTECTED]> wrote:
> Hm.  This brings up another point, which may have been addressed . . .
>
> The Python function and Ruby array method zip() both accept any number of
> arrays to interleave:
>
> >>> zip([1,2,3],[4,5,6],[7,8,9])
> [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
>
> irb(main):001:0> [1,2,3].zip([4,5,6],[7,8,9])
> => [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
>
> How would you write the above in Perl6, given that ¥/Y is an infix operator?

Ah, ¥ is not a binary infix operator.  Instead, it is what Damian
calls "list-associative".  Another such operator is junctive ^, for if
it were binary, it would be an xor, not a one.

As far as the syntax goes, well, we'll have to make some up.

    sub listfix:<¥> (Array [EMAIL PROTECTED]) {...}
    sub infix:<¥> is assoc('list') (Array [EMAIL PROTECTED]) {...}

Or something like that.

However, if I get my wish of having zip return tuples, then it can be
left-associative.  But since it interleaves instead, making it left-
or right-associative gives strange, incorrect results.

Luke

Reply via email to