Fished up from the blogosphere:
 
>From a set of letters, say 'letterbrei', I want to produce a set of the
longest possible words (checked against a reference list). Reading about
symbol s: I decided to use this to make a lookup table of sorted words
from the imported word list. Here's my interpretation:


NB. word list
wb =: 'b' fread <'/usr/share/dict/words'

   # wb
380645


NB. build a symbol table from the word list
wbs=: s: /:~&.> wb

NB. lookup function
lu=: wb{ ~ [: I. wbs e. s:@<

NB. powerset function, e.g.
ps=: (],,&.>)/@(a:,~,&.>)

Example of use:

NB.      desc. sort by length            unique subsets with minimum
length 3
   ts '6 {. ({~\:@:(#&.>)) ; lu &.> (#~[:;2&<@#&.>) ~. ps /:~
''letterbrei'''
8.977938 639296
+--------+--------+--------+--------+--------+--------+
|litterer|letterer|reletter|brittler|bitterer|terrible|
+--------+--------+--------+--------+--------+--------+


Question is are there alternatives I should know of?


Thanks

=@@i

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to