Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Best way to sum an array?

by BrowserUk (Patriarch)
on May 25, 2017 at 15:44 UTC ( [id://1191226]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #! perl -sl
    use List::Util qw[ sum ];
    ...
    our $N //= 10;
    
    print sum( 1 .. $N );
    
  2. or download this
    #! perl -sl
    #use List::Util qw[ sum ];
    ...
    my $t = 0;
    $t += $_ for 1 .. $N;
    print $t;
    
  3. or download this
    [16:27:32.60] C:\test>for /l %i in (1,1,10) do WithListUtil.pl -N=3
    [16:27:55.68] C:\test>WithListUtil.pl -N=3
    ...
    [16:28:22.80] C:\test>WithoutListUtil.pl -N=3
    [16:28:22.84] C:\test>WithoutListUtil.pl -N=3
    [16:28:22.88] C:\test>
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found