in reply to Re: Golf: Adding up array elements
in thread Golf: Adding up array elements
eval join"+",@_
Of course, that's not safe if @_ includes a text element with a ";" in it.
But in the spirit of silly shortenings, how about some recursion?
sub sum { @_ && pop(@_) + sum(@_) }
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Golf: Adding up array elements
by Skeeve (Parson) on Nov 02, 2005 at 18:29 UTC | |
by tilly (Archbishop) on Nov 03, 2005 at 05:29 UTC | |
by Aristotle (Chancellor) on Nov 03, 2005 at 14:23 UTC | |
by Perl Mouse (Chaplain) on Nov 03, 2005 at 16:36 UTC |