The nub (and related functions) of a multi-column
table can be computed by self-indexing on each
column and then further computations on the
table of combined indices:
x=: 1e4 4 [EMAIL PROTECTED] 100 0 200 0
(~.x) -: (~: i.~"1&.|: x) # x
1
This method can be used on the inverted form of a
relation where the columns are individually boxed:
a=: <(1e4 [EMAIL PROTECTED] 6){>;:'Stanford Harvard Cornell Yale Amherst
Oxford'
a=: a, <1e4 [EMAIL PROTECTED] 100
a=: a, <(1e4 [EMAIL PROTECTED] 2){'mf'
,.&.> 5{.&.> a
+--------+--+-+
|Harvard |76|f|
|Oxford |42|f|
|Yale |12|m|
|Stanford|80|f|
|Oxford | 1|f|
+--------+--+-+
b=: ~: |: i.~&> a
b1=: ~: a1=: > ,.&.>/ ":@,.&.> a
5{.a1
Harvard 76f
Oxford 42f
Yale 12m
Stanford80f
Oxford 1f
b -: b1
1
b2=: ~: a2=: |: <"_1&> a
5{.a2
+--------+--+-+
|Harvard |76|f|
+--------+--+-+
|Oxford |42|f|
+--------+--+-+
|Yale |12|m|
+--------+--+-+
|Stanford|80|f|
+--------+--+-+
|Oxford |1 |f|
+--------+--+-+
b -: b2
1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm