RosettaCodeData/Task/Ordered-words/M2000-Interpreter/ordered-words.m2000
2026-02-01 16:33:20 -08:00

38 lines
1,018 B
Text

module Ordered_Words {
orderword=lambda ->{
buffer a as integer*30
=lambda a (s as string) -> {
if len(s)*2>len(a) then buffer a as integer*len(s)
return a, 0:=s
if len(s)=1 then =true: exit
for i=1 to len(s)-1
if a[i-1]>a[i] then break
next i
=true
}
}()
max=2
res=stack
document a$
load.doc a$, "unixdict.txt"
k=doc.par(a$)
i=0
m=Paragraph(a$, 0)
if forward(a$, m) then
while m
i++
if i mod 20=1 then Print Over round(i/k*100,2);"%" : refresh
word=paragraph$(a$, (m))
if orderword(word) then
if max<len(word) then max=len(word): res=stack
if max=len(word) then stack res {data word}
end if
end while
print
end if
open "outtxt.txt" for output as #f
Print #f, "words:", array(res)#str$(" ")
close #f
win dir$+"outtxt.txt"
}
Ordered_Words