in reply to Golf: Adding up array elements
The obvious way to golf it:
sub sum { my$t;$t+=$_ for@_;$t }
The eval approaches are shorter, but unsafe. It’s your call whether that’s acceptable. For real code, it’s not. But in real code I’d use List::Util.
Update: added space as per sauoq.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Golf: Adding up array elements
by sauoq (Abbot) on Nov 02, 2005 at 23:08 UTC |