longest word in a text

Jeanne A. E. DeVoto revolution at jaedworks.com
Fri Jul 14 15:19:48 EDT 2006


At 8:46 PM +0200 7/14/2006, jbv wrote:
>Does anyone have some very fast code to find the longest word
>(number of chars) in a text ?

This one was the fastest of those I tested:

function longestWord myText
   repeat for each word thisWord in myText
     put thisWord into myArray[the length of thisWord]
   end repeat
   get the keys of myArray
   replace return with comma in it
   return myArray[max(it)]
end longestWord

-- 
jeanne a. e. devoto ~ revolution at jaedworks.com
http://www.jaedworks.com



More information about the use-livecode mailing list