Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: How can I improve the efficiency of this very intensive code?by polettix (Vicar) |
on Aug 07, 2005 at 00:07 UTC ( [id://481576]=note: print w/replies, xml ) | Need Help?? |
This is exactly what I was going to suggest, apart from a minor optimisation regarding the initialisation of the first value. The I recalled of the existence of reduce in List::Util, which does the job nicely. But maybe I should have been less cryptic and explain what the solution does exactly - thanks for the example, I'll update my post linking to it :)
I know it's a corner case that should not happen, but I'd check for $i2 to be defined before comparing it against $id2. Flavio
In Section
Seekers of Perl Wisdom
|
|