Ordered words: Difference between revisions

Added missing type; removed HTTP access as file cannot be loaded at the given address (so used a local copy); other minor changes.
(Added missing type; removed HTTP access as file cannot be loaded at the given address (so used a local copy); other minor changes.)
Line 2,875:
 
=={{header|Nim}}==
<lang nim>import httpclient, strutils
 
const DictFile = "unixdict.txt"
proc isSorted(s): bool =
 
var last = low(char)
procfunc isSorted(s: string): bool =
var last = low(char).low
for c in s:
if c < last: return false
return false
last = c
returnresult = true
 
var
const url = "http://www.puzzlers.org/pub/wordlists/unixdict.txt"
var mx = 0
var words: seq[string] = @[]
 
for word in getContent(url)DictFile.split()lines:
if word.len >= mx and isSorted(word).isSorted:
if word.len > mx:
words = @[].setLen(0)
mx = word.len
words.add( word)
echo words.join(" ")</lang>
{{out}}
Output:
<pre>abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</pre>
 
Anonymous user