RosettaCodeData/Task/Ordered-words/Lingo/ordered-words.lingo
2016-12-05 23:44:36 +01:00

27 lines
604 B
Text

-- Contents of unixdict.txt passed as string
on printLongestOrderedWords (words)
res = []
maxlen = 0
_player.itemDelimiter = numtochar(10)
cnt = words.item.count
repeat with i = 1 to cnt
w = words.item[i]
len = w.length
ordered = TRUE
repeat with j = 2 to len
if chartonum(w.char[j-1])>chartonum(w.char[j]) then
ordered = FALSE
exit repeat
end if
end repeat
if ordered then
if len > maxlen then
res = [w]
maxlen = len
else if len = maxlen then
res.add(w)
end if
end if
end repeat
put res
end