in reply to Re: Best way to sum an array?
in thread Best way to sum an array?
I would say you really don't need to worry about either speed or accuracy of summation in "normal" circumstances.
Often the question "Which is the fastest way" can be translated into "The way I doing it now is really slow; how can I improve it."
With List::Util::sum() running 100x faster than the best pure perl equivalent, why wouldn't you use it even if you don't need the speed; and for some of the methods attempted by beginners and even experienced programmers new to Perl -- eg. the recursive solution in the OP -- sum() can be almost 1000 times faster. Perl sucks at recursion.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Best way to sum an array?
by hippo (Archbishop) on May 25, 2017 at 12:54 UTC | |
by BrowserUk (Patriarch) on May 25, 2017 at 15:44 UTC | |
by hippo (Archbishop) on May 25, 2017 at 16:08 UTC | |
by BrowserUk (Patriarch) on May 26, 2017 at 07:03 UTC | |
by LanX (Saint) on May 25, 2017 at 13:01 UTC |