Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^10: Finding repeat sequences.

by BrowserUk (Patriarch)
on Jun 21, 2013 at 19:28 UTC ( [id://1040213]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Finding repeat sequences.
in thread Finding repeat sequences.

Interesting that my last modification timed out. Did you run it with $i or $i+1?

Exactly as you posted it (c&p).

I just added print "i:$i j:$j"; to the bottom of the loop and it shows what happens:

i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 ...

Your concern about my use of $i+1 ignores the difference in the relative ordering of the ++$i increment in my version and yours. (The original.)

And your addition of the if statement never avoids the need to perform the index, so is pure overhead.

As for the possibility of out-by-one errors:

I'll trade the need to fix them, for the ability to make them; when the alternative is to rely upon the (unseen, unknown, uncontrollable, and possibly non-existent) generic optimisations of a declarative tool to convert a high-level -- and potentially completely broken -- abstract description of my problem into an efficient solution.

Had I opted for that approach, I would have settled on Damian's original solution. There would have been no incentive for him to improve it; or you to correct and improve yours.

The result would have been that my application for this; currently running on one of my 4 cores and projected to run for 7 to 10 days; would have projected to run for 143 1110 years! In other words, it would have been abandoned.

Far too often people settle for the first solution on offer -- cpan -- and never consider the affect their choices have.

So yes, I'll willingly trade the need to correct out-by-one errors; for the ability to make them in the first place.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found