Ordered words: Difference between revisions

Content added Content deleted
(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: Line 2,429:


=={{header|J}}==
=={{header|J}}==
<lang j>NB. from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
<lang j> require'web/gethttp'
dict=: gethttp'http://www.puzzlers.org/pub/wordlists/unixdict.txt'
oWords=: (#~ ] = /:~L:0) cutLF CR-.~fread 'unixdict.txt'
oWords=: (#~ ] = /:~L:0) <;._2 dict-.CR
;:inv (#~ (= >./)@:(#@>)) oWords
;:inv (#~ (= >./)@:(#@>))oWords
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</lang>
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</lang>


Recap:
Recap:


# fetch dictionary (<code>dict</code>)
# read dictionary (<code>CR-.~fread 'unixdict.txt'</code>)
# break into words, one per line (<code><;._2 dict-.CR</code>)
# break into words, one per line (<code>cutLF</code>)
# find ordered words (<code>oWords</code>)
# find ordered words (<code>(#~ ] = /:~L:0)</code>)
# select the longest ordered words (<code>(#~ (= >./)@:(#@>))oWords</code>)
# select the longest ordered words (<code>(#~ (= >./)@:(#@>))oWords</code>)
# format for display (using ;:inv)
# format for display (using ;:inv)