Brian's "under" solution is pretty and easy to read. Here is another one
transpose version (but not shorter) and a varinat on the ridiculous:
]a=: (?.@$ */)2 3 6
30 35 35 4 2 27
20 25 4 2 30 14
1 10 7 20 34 24
10 6 11 28 0 12
24 35 13 35 0 10
5 29 32 24 18 19
|: (i. >./)"1 |: a
0 0 0 1 0 0
1 1 1 1 0 0
1 1 1 1 0 0
(0&|: i."1 0 >./) a
0 0 0 1 0 0
1 1 1 1 0 0
1 1 1 1 0 0
A variant of the ridiculous:
]b=:(?.@$ */)3 4 6
66 35 71 4 38 63
20 25 4 2 30 14
1 46 7 20 34 60
10 6 47 28 0 12
60 71 13 35 36 10
41 65 68 24 18 55
43 17 15 49 9 44
37 1 69 40 28 57
29 11 5 60 61 36
33 31 21 41 54 19
1 1 10 43 49 32
53 37 49 17 47 27
|: (i. >./)"1 |: b
0 1 0 2 2 0
1 1 1 2 2 1
1 0 1 1 2 0
2 2 1 1 2 1
(i.@{.@:$ +/ . * (="2 >./)) b
0 1 0 2 2 0
1 1 1 2 2 1
1 0 1 1 2 0
2 2 1 1 2 1
Although for arrays higher than 3d I think you want
(i.@{.@:$ +/ . * ] ="_1 _ >./) b
0 1 0 2 2 0
1 1 1 2 2 1
1 0 1 1 2 0
2 2 1 1 2 1
Best, Cliff
On 8/26/2011 10:32 PM, David Ward Lambert wrote:
> Is there a shorter sentence? [: |: [: (i.>./)"1 |:
>
> I'm thinking this could work: i."SOME RANK>./
>
> ]a=: (?.@$ */)2 3 6 NB. data, rank 3
> 18 20 28 30 29 28
> 22 28 8 7 21 32
> 31 17 25 32 33 28
>
> 13 17 29 15 1 25
> 18 28 33 26 22 9
> 17 6 34 15 23 35
>
> >./a NB. want the index of a plane having these maximums
> 18 20 29 30 29 28
> 22 28 33 26 22 32
> 31 17 34 32 33 35
>
> NB. this works but involves two transposes
> |: (i.>./)"1 |: a
> 0 0 1 0 0 0
> 0 0 1 1 1 0
> 0 0 1 0 0 1
>
> NB. this version is ridiculous
> <./ (<:@+>:@# * 0 = ]) (>:@i.@# * (="2>./)) a
> 0 0 1 0 0 0
> 0 0 1 1 1 0
> 0 0 1 0 0 1
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Clifford A. Reiter
Lafayette College, Easton, PA 18042
http://webbox.lafayette.edu/~reiterc/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm