I don't have the file to test with, but I offer
(#~a:~:{:"1)(/.~/:~&.>)<;._2 toJ fread jpath'~temp\unixdict.txt'
Use the sorted strings as the keys without converting to
numbers; don't box the results but allow them to fill
a table; longest sets will be the ones without a: at the end.
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Dan Bron
> Sent: Thursday, September 25, 2008 2:55 PM
> To: Programming forum
> Subject: [Jprogramming] Words of Equal Characters
>
> Recently, I've been playing around on Rosetta Code [1]. A
> Python guy posted a new task:
>
> http://rosettacode.org/wiki/Words_Of_Equal_Characters
>
> What is the shortest possible J expression to solve this
> task? Here, "shortest" means the minimum number of
> essential (required) characters. Right now, I have:
>
> >(#~[:(=>./)#&>)(</.~[:i.~/:~&.>)<;._2 toJ fread
> jpath'~temp\unixdict.txt'
> +-----+-----+-----+-----+-----+
> |abel |able |bale |bela |elba |
> +-----+-----+-----+-----+-----+
> |alger|glare|lager|large|regal|
> +-----+-----+-----+-----+-----+
> |angel|angle|galen|glean|lange|
> +-----+-----+-----+-----+-----+
> |caret|carte|cater|crate|trace|
> +-----+-----+-----+-----+-----+
> |elan |lane |lean |lena |neal |
> +-----+-----+-----+-----+-----+
> |evil |levi |live |veil |vile |
> +-----+-----+-----+-----+-----+
>
> which is shorter than the original Python solution, but not
> dramatically shorter. Is there a way to code this to really
> show off J's power? I'm more focused on the aspect that
> produces the result given a list of words, rather than the
> aspect that generates the list of words from the text (i.e.
> I'm seeking to minimize the code to the left of the cut).
>
> -Dan
>
> [1] Rosetta Code is what it sounds like -- a chrestomathy
> site where programmers are invited to solve programming tasks
> using different languages, to build up a "Rosetta Stone" for
> different programming languages.
>
> Of course, the primary motivation for posting a solution to
> Rosetta Code is not to teach others your language, or to make
> it easier for a maintenance programmer to convert a legacy
> system from COBOL to Perl. Those are just side effects.
> The primary motivation for posting a solution to Rosetta Code
> is to brag. It's main constituency is evangelists. It's the
> premier public programming pissing match.
>
> One drawback of Rosetta Code is that only the results of the
> programmer's efforts are visible; there's no way to tell how
> long the solution took, or how the language enabled the
> programmer to reach the solution. So even though this
> solution (the "obvious way") took me less than a minute to
> write, no one reading the page will know that. The only
> opportunity to "wow" the audience is with a succinct, elegant
> solution. And since most of the audience won't be able to
> read J, elegant is less important than succinct. That's why
> I'm seeking an impressively short solution to this task
> (which seems right up J's alley).
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm