Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: map vs for\foreach.

by sn1987a (Deacon)
on Mar 11, 2015 at 14:33 UTC ( [id://1119641]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach(@a){$_+=1;};
    
    real    0m4.941s
    user    0m1.096s
    sys    0m3.604s
    
  2. or download this
    @a = map{$_+= 1} @a;
    
    real    0m6.248s
    user    0m2.652s
    sys    0m2.900s
    
  3. or download this
    map{$_+= 1} @a;
    
    real    0m3.224s
    user    0m2.908s
    sys    0m0.232s
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-19 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found