in reply to Finding all substrings

The root of optimization is finding a solid algorithm, then implementing it, then speeding the implementation. You algorithm is solid (I don't know of a faster one . . .monks?) and your implementation is simple, meaning not much room for speed gain. Offhand though, C style for loops might be slightly faster (perl does an implicit ++ and check when you call the range operator, hence the rationale that doing it directly might be faster).

Cheers,
Erik

Replies are listed 'Best First'.
Re: Re: Finding all substrings
by samtregar (Abbot) on Apr 24, 2002 at 18:24 UTC
    I disagree. The root of optimization is finding a solid algorithm, implementing it, tuning it and then finding a way to exploit caching to make it faster. See my solution below for an example. See Memoize for another option.

    -sam