develooper Front page | perl.perl6.language | Postings from August 2005

Re: zip with ()

Thread Previous | Thread Next
Larry Wall
August 4, 2005 11:16
Re: zip with ()
Message ID:
On Mon, Aug 01, 2005 at 01:13:52PM +0200, "TSa (Thomas SandlaƟ)" wrote:
: BTW, you didn't mean originally:
:   say zip (@odd), (@even); # prints 13572468 or 12345678?

That doesn't work, since () in list context does not enforce scalar context.
It's exactly equivalent to

    say zip @odd, @even;

which is also wrong, because zip is requires "multidimentional slice"
syntax.  Ordinary commas will be taken to separate items of the first
slice.  To separate slices requires semicolon or pipes.

: Does &zip now interleave two array refs instead
: of flattened arrays?

No, but separating the arrays with comma doesn't work either, so Pugs
currently has it wrong.  The correct syntax will eventually be:

    zip(@odd; @even)
    zip @odd <== @even

The parens are required only at the top statement level.  Inside other
bracketing structures you can omit the parens:

    (zip @odd; @even)

just as in subscripts the semicolon separates multiple dimensions:

    @foo[@a; @b]


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About