Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: (almost) foldl

by Grimy (Pilgrim)
on Jun 08, 2011 at 10:07 UTC ( #908677=note: print w/replies, xml ) Need Help??


in reply to Re^2: (almost) foldl
in thread (almost) foldl

sub sum { eval 'pop(@_)+' x ($#_ + 1) . '0'; } @list = (-4, 15, -5, 2.5); print sum @list; # 8.5, as expected print sum -4, 15, -5, 2.5; # Works the same print sum; # 0 (not undef)
EDIT: replaced $#list with $#_ , so that it works with lists of any length. Silly me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://908677]
help
Chatterbox?
[GotToBTru]: have you looked on CPAN?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-02-22 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (335 votes). Check out past polls.