I'll be surprised if there's anything much better than the first program you
offered. My only recommendation is to use Laminate rather than Stitch:

( ~.@[ ,: +//. )/

Doing this we hold to the row-wise orientation that is natural for Key, vs
the column-wise orientation given in the inquiry. If there is some
importance to the columnar orientation it can be managed outside the main
verb, perhaps with Under Transpose:

(~.@[ ,: +//.)/ &.|: arr

The use of Nub to associate the keying values seems relatively awkward, but
I'm not aware of an elegant alternative.

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

Reply via email to