Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Better Way to Combine Two Arrays

by chip (Curate)
on Mar 10, 2004 at 17:46 UTC ( [id://335534]=note: print w/replies, xml ) Need Help??


in reply to Better Way to Combine Two Arrays

Parentheses are your friends.

@nums = ( (map q|1234560| . $_, 1..9 ), (map q|1321343| . $_, 10..99) );

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re^2: Better Way to Combine Two Arrays
by bart (Canon) on Mar 11, 2004 at 11:57 UTC
    That's how I'd write it too...

    However, I'd like to point out that map actually is a function, so you can use parentheses in the way tha is common for any other function:

    @nums = ( map(q|1234560| . $_, 1..9 ), map(q|1321343| . $_, 10..99) );
      But I'm not fond of the map EXPR syntax. A block of executable code should look like a block of executable code, and be different from the always-evaluated input list. Or so it seems to me.

      Unfortunately I recently found out that map BLOCK is actually a bit slower than map EXPR. I might fix that one of these days.

          -- Chip Salzenberg, Free-Floating Agent of Chaos

        But I'm not fond of the map EXPR syntax. A block of executable code should look like a block of executable code
        Huh... me too, actually.
        Unfortunately I recently found out that map BLOCK is actually a bit slower than map EXPR.
        Entering and exiting an extra scope?

        Perhaps you could optimize it by skipping the scoping steps in case there are no lexical variables declared in it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://335534]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found