Bjorn;

Nice ... for the rest of us.

David

On Sun, 2008-08-17 at 19:42 +0000, Björn Helgason wrote:
> I am just wondering if the beginner understands what happened and what magic
> Roger performed.
> 
> These kind of solutions are of course brilliant and telling of the power of
> J.
> 
> I personally do understand it but fro the sake of the beginner it would be
> nice to put some comments in.
> 
> create a verb containing the string of items one on each line or in its own
> box as one prefers.
> split each line or item in subitem depending on blanks
> create a list of all unique items in the lists
> Look for all occurances in the original list
> 
> As an exercise it is best to split the operations into pieces and
> investigate each step
> 
> 
>    [a=:'ab'; 'abc de'; 'ab de'; 'de ef'
> +--+------+-----+-----+
> |ab|abc de|ab de|de ef|
> +--+------+-----+-----+
> 
>    [all=:chop each a
> +----+--------+-------+-------+
> |+--+|+---+--+|+--+--+|+--+--+|
> ||ab|||abc|de|||ab|de|||de|ef||
> |+--+|+---+--+|+--+--+|+--+--+|
> +----+--------+-------+-------+
> 
>    [uni=: ~. ;all
> +--+---+--+--+
> |ab|abc|de|ef|
> +--+---+--+--+
> 
>    uni ,. <@I."1 |: (<uni) e.&> all
> +---+-----+
> |ab |0 2  |
> +---+-----+
> |abc|1    |
> +---+-----+
> |de |1 2 3|
> +---+-----+
> |ef |3    |
> +---+-----+
> 
> 
> 
> 2008/8/17 Raul Miller <[EMAIL PROTECTED]>
> 
> > On Sun, Aug 17, 2008 at 10:39 AM, Roger Hui <[EMAIL PROTECTED]> wrote:
> > > s=: 'ab',LF,'abc de',LF,'ab de',LF,'de ef',LF
> > > w=: <;._1@(' '&,)&.> <;._2 s
> > > u=: ~. ; w
> > > u ,. <@I."1 |: (<u) e.&> w
> >
> > I would have been tempted to use
> > w=: <@;:;._2 s
> > u=: ~. ; w
> > u,.u [EMAIL PROTECTED]:1 w
> >
> > (or maybe even a variable-free rephrasing of that?)
> >
> > But, without knowing what a "sentence" was, maybe my use of ;:
> > would not be a good thing?
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> 
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to