Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

map versus for

by dHarry (Abbot)
on Aug 04, 2008 at 14:40 UTC ( [id://702071]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    List Generation
    
    Use map instead of for when generating new lists from old.
    
  2. or download this
    use strict;
    use warnings;
    ...
    sub test_map {
        my @sqrt_results = map { sqrt $_ } @results;
    }
    
  3. or download this
    $count=-1
    (warning: too few iterations for a reliable count)
    ...
          Rate for map
    for 2.73/s  -- -8%
    map 2.95/s  8%  --
    
  4. or download this
    $count=-1
    
    ...
    Benchmark: running for, map for at least 10 CPU seconds...
           for: 10 wallclock secs (10.11 usr +  0.00 sys = 10.11 CPU) @  3
    +.46/s (n=35)
           map: 10 wallclock secs (10.03 usr +  0.00 sys = 10.03 CPU) @  3
    +.29/s (n=33)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found