RosettaCodeData/Task/Ordered-words/TAV/ordered-words.tav
2025-08-11 18:05:26 -07:00

20 lines
674 B
Text

main(params):+
res =: [] \ to hold the words
maxw =: 0 \ maximum wordlength
?# w =: file 'unixdict.txt' give lines
fault w print stop \ message and stop if error
? (is ordered w) & w.count >= maxw
? w.count > maxw \ longer word,
res =: [] \ reset list
res[] =: w \ store at next index in list
maxw =: w.count \ update
print row res join values by ' '
\ check word (w)
is ordered (w):
cc =: ' ' \ smallest character
?# i =: from 1 upto w.count
? w[i] < cc
:> ?- \ failed
cc =: w[i]
:> ?+