I'm being lazy here. But I need a better answer than I can devil out
myself. It occurs in a recent submission to Vector...
I have an array like this (which may be unsorted, and can grow very large):
1 100
1 100
1 20
1 400
2 30
2 200
2 300
33 100
33 100
33 100
I want to collapse it to:
1 620
2 530
33 300
i.e. summing over subheadings.
The original example had A B C in place of 1 2 33, but numbers will
do, to save boxing. We don't know the full set of A B C ... in
advance. Nothing to be assumed about the first column, except it is
+ve integers. But I'm also interested in the case where the first
column lies in the set: i.(n) for some n>0. In other words they can be
squashed up.
1. There's simply got to be a "jem" to do it. Suggestions, please.
- Transpose the array if you wish. Box it: 1 100 ; 1 100 ; 1 20 ; ...
-whatever.
- No, of course I don't want a looping solution :)
2. What do you call this process? I call it "aggregation" -- but I
think the name differs across disciplines.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm