finding repeating patterns
Mark Smith
mark at maseurope.net
Sun Aug 27 13:33:05 EDT 2006
Here's my version:
function getRepeatingPatterns tString,minLength,maxLength
set the caseSensitive to true
repeat with n = minLength to maxLength
put empty into testString
put 0 into charCount
repeat for each char c in tString
put c after testString
get length(testString)
if it < n then next repeat
if it > n then delete char 1 of testString
if space is in testString then next repeat -- optional
if cr is in testString then next repeat -- optional
add 1 to countArray[testString]
end repeat
end repeat
repeat for each line L in the keys of countArray
if countArray[L] > 1 then put L && countArray[L] & cr after
countList
end repeat
delete char -1 of countList
sort lines of countList
return countList
end getRepeatingPatterns
On 26 Aug 2006, at 23:23, jbv wrote:
> for those interested, here's something much faster :
>
> on mouseUp
> set cursor to watch
> lock screen
> put fld 1 into myST
> put number of chars of myST into n
> put "" into myL
> set the casesensitive to true
> put 1 into k
> repeat while k<=1000
> repeat with i=100 down to 6
> put k+i-1 into b
> get char k to b of myST
> put myST into a
> replace it with "" in a
> put ((n - number of chars of a) / b) into c
> if c>=2 then
> put it & tab & c & cr after myL
> add b-1 to k
> exit repeat
> end if
> end repeat
> add 1 to k
> end repeat
> put myL
> end mouseUp
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list