On Thu, Sep 25, 2008 at 4:20 PM, Sherlock, Ric
<[EMAIL PROTECTED]> wrote:
> You could use freads instead of toJ fread.
>
> (#~a:~:{:"1)(]/.~/:~&.>)<;._2 freads jpath'~temp\unixdict.txt'Neither fread nor freads is defined in J by default. To make the above code work you should prefix it with the line: require'files' Also, I think that for rosetta code to be useful it should be documented. Documentation should not count against the code length, since the code will work just fine without it, but documentation can help orient human readers. Also, I did not notice any useful result from toJ in this context, based on the file I retrieved using: wget http://www.puzzlers.org/pub/wordlists/unixdict.txt Also, you might as well store that file directly in your main J directory, since getting the file someplace useful is outside the scope of the exercise. I also noticed that if I heeded Roger Hui's advice and replaced /:~&.> with /:~&.> I did not see any significant change in time (just random variation) but I did use slightly less space (on a 64 bit system). I would, however, leave the file name alone so that I do not lose my readers. Thus: (#~a:~:{:"1)(]/.~/:~&.>)<;._2]1!:1<'unixdict.txt' And, for my comments (assuming that comments are actually acceptable on that site -- I do not know): Read file and convert to list of boxed words (assume one word per line): <;._2 ] 1!:1 <'unixdict.txt' Arrange boxed words in rows keyed by their anagrams (]/.~ /:~&.>) Select rows where the last box is not empty (#~ a: ~: {:"1) FYI, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
