Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Golf: Adding up array elements

by ioannis (Priest)
on Nov 02, 2005 at 16:57 UTC ( #505002=note: print w/ replies, xml ) Need Help??


in reply to Golf: Adding up array elements

Besides brevity, it might also execute faster since Util.xs informs us that sum() is coded in C, as NV sum(...)

use List::Util qw(sum); print sum (my @arr = qw( 1 3 5 6));


Comment on Re: Golf: Adding up array elements
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2014-07-10 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (211 votes), past polls