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

Reply via email to