http://www.perlmonks.org?node_id=350569


in reply to Re: fast bit twiddling
in thread fast bit twiddling

There's a mistake here, since the eq operator has an higher precedence than the comma.
The sub should be written this way:
sub buk2{ my $s = shift; substr($s, $_-1, 1) eq substr($s, $_, 1) and return for @_; return 1; }
Oddly enough, after the correction above this solution proves to be the fastest (probably because it reaches the first return more frequently.)
See here for the updated benchamark results.

Cheers, Emanuele.

Replies are listed 'Best First'.
Re: Re: Re: fast bit twiddling
by BrowserUk (Pope) on May 04, 2004 at 22:08 UTC

    Nice pickup.++


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
      Congratulations for the fastest solution ;-) ++