Ordered words: Difference between revisions

m
→‎{{header|J}}: url for unixdict.txt had changed, and it's probably more polite to use a locally cached copy
(Frink)
m (→‎{{header|J}}: url for unixdict.txt had changed, and it's probably more polite to use a locally cached copy)
Line 2,429:
 
=={{header|J}}==
<lang j>NB. from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
<lang j> require'web/gethttp'
dictoWords=: gethttp'http:(#~ ] = //www:~L:0) cutLF CR-.puzzlers.org/pub/wordlists/~fread 'unixdict.txt'
oWords=;:inv (#~ ] (= >./)@:~L:0(#@>)) <;._2 dict-.CRoWords
;:inv (#~ (= >./)@:(#@>))oWords
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</lang>
 
Recap:
 
# fetchread dictionary (<code>dictCR-.~fread 'unixdict.txt'</code>)
# break into words, one per line (<code><;._2 dict-.CRcutLF</code>)
# find ordered words (<code>oWords(#~ ] = /:~L:0)</code>)
# select the longest ordered words (<code>(#~ (= >./)@:(#@>))oWords</code>)
# format for display (using ;:inv)
6,962

edits