$10K coding deathmatch

Alan Young alansyoungiii at gmail.com
Thu Nov 2 22:47:11 MST 2006


Andy Bradford wrote:
> Perl: .0125ms on average

Which one?  I'd be curious to see the difference between the full check
and the short circuit version.  Actually, I can do that myself:

perl -ape '$_=((grep{(abs($F[$_]-$F[$_-1])||@F)>=@F}1..$#F)?"not a
":"")."match\n"' test.txt

real    0m0.010s
user    0m0.000s
sys     0m0.004s

perl -ape '$_="match\n";$i=0;while(++$i<@F){last
if(abs$F[$i]-$F[$i-1]||@F)>=@F and $_="not a $_"}' test.txt

real    0m0.010s
user    0m0.000s
sys     0m0.012s

Wow.  I thought the short-circuit would make it faster ... of course,
the test data was extremely small.



More information about the PLUG mailing list