Re: Newbie. How do I count "i"?
Re: Newbie. How do I count "i"?
- Subject: Re: Newbie. How do I count "i"?
- From: email@hidden (Michael Sullivan)
- Date: Sun, 27 Jan 2002 12:52:43 -0500
- Organization: Society for the Incurably Pompous
John Baxter writes:
>
That's probably what I would do (for case sensitive). But...regardless of
>
method, one's test case should include some double (or longer) i sequences.
>
And strings with leading and trailing i characters. Encouragingly, the
>
string "iixyzii" counts to 4 (as it should) using the TID method. But that
>
one string isn't a full test by any means.
It's not, but I've done a lot of testing of TIDs in this way, and so far
it's been completely consistent that a string with two delimiters in a
row gets represented as having an item of "" in the list produced, and
strings which start with the delimiter or end with a delimiter have an
empty string at the beginning or end as required.
I believe this method is safe, and very likely to be the fastest one
available.
The only problem with it is if you have long strings with possibly very
many instances (over 4000 or so) of the delimiter, in which case it can
generate a stack overflow. The solution there would be an algorithm to
break down strings into sufficiently small chunks and then work on the
chunks one by one. I have a GroupTheString handler I wrote in response
to a question about such chunking on the list a few months ago, and I
can send it if the original poster wants it. I think has or someone
might have put a similar handler up on Applemods already (If not, I'll
eventually submit mine).
Michael