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

Re: How can I add all the numbers in an array with out doing a foreach loop?

by aaron_baugher (Curate)
on Oct 20, 2013 at 16:57 UTC ( [id://1059023]=note: print w/replies, xml ) Need Help??


in reply to How can I add all the numbers in an array with out doing a foreach loop?

Surprised no one's added the Lisp-style recursive solution yet:

sub radd { return( defined $_[0] ? $_[0] + radd(@_[1..$#_]) : 0 ); } my $sum = radd(1..10);
  • Comment on Re: How can I add all the numbers in an array with out doing a foreach loop?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found