I think I'm not understanding the significance of the right argument in the first example use of keyD. Or, at least, I can get the same result without that 'abcdefg' argument:
(/:~ </. /:) 1 2 3 1 3 2 1 ┌─────┬───┬───┐ │0 3 6│1 5│2 4│ └─────┴───┴───┘ (And I suppose I should point out that the second example can be similarly rephrased: (# - #/.~) 1 2 3 1 3 2 1 ). That said, I don't know enough about the real application to know if it's reasonable to doing anything different there. -- Raul On Fri, Jan 13, 2017 at 9:55 PM, 'Pascal Jasmin' via Programming <[email protected]> wrote: > dictionary gives a hint how to do this, but this is neat > > keyD =: 1 : '(=@[) (] (u >)"_ 0 <@#) ]' > > 1 2 3 1 3 2 1 <@i. keyD 'abcdefg' > ┌─────┬───┬───┐ > │0 3 6│1 5│2 4│ > └─────┴───┴───┘ > > u is a dyadic verb, and will be called with y u (keyed y items) for each > key. Boxes to avoid fills. > > -&# keyD~ 1 2 3 1 3 2 1 > 4 5 5 > > above are toy applications, but a real one is a list of records that link to > each other, and you wish to walk through the links. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
