Heads & Tails
Mark Greenberg
markgreenberg at cox.net
Fri Dec 9 15:58:46 EST 2005
Yes, but the original post (quite a while ago) was looking for a way
to determine how many times h occurred in singles, doubles, triples,
etc. Your script counts how many heads and tails there are total.
There were some non-RegEx solutions offered, but they were long.
RegEx shortens the length of the solution quite a bit. I can't
determine whether the RegEx solution is faster because I am using an
older version of Rev which has slower RegEx.
Mark
On Dec 9, 2005, at 10:21 AM, Jim Hurley wrote:
> The many ways of skinning a cat:
>
> on mouseUp
> put field 1 into tText
> put 0 into tHeads
> repeat for each char tChar in tText
> if tChar is "h" then add 1 to tHeads
> end repeat
> put the number of chars in tText - tHeads into tTails
> put tHeads, tTails into msg box
> end mouseUp
>
> Given field 1 of the form hhhththhthhhth
>
> Jim
More information about the use-livecode
mailing list