Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: fast bit twiddling

by emazep (Priest)
on May 04, 2004 at 21:13 UTC ( #350569=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Re: fast bit twiddling
Download Code
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 ;-) ++

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350569]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-12-26 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls