Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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.

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 ;-) ++

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350569]
help
Chatterbox?
[choroba]: programming is easy once you know how to solve the problem
[shmem]: choroba: yeah, adjusting the screw 2 - knowing which one 42
[shmem]: and - on another side: a complete spec is identical to the programs source code
[shmem]: it is just written in another language
[choroba]: that's why we have agile - we don't have any spec
[shmem]: I'm a bit scared by agile (agile imposition) - but then it is crucial how it is lived to crucified or not

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-04-27 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (508 votes). Check out past polls.