There is a way: you transpose the argument array, apply the desired operation, then possibly transpose the result (as Brian's answer indicates). An efficient implementation would do this under the covers anyway for nearly all of the column-wise operations that can't be implemented using rank.
The design of J is based in part on the idea that arrays are a special kind of nested list, which naturally privileges earlier axes. If you find that you need to group columns more often than rows, it's likely that your data is stored in the wrong format. Marshall On Mon, Nov 27, 2017 at 10:12:56AM +0100, Erling Hellenäs wrote: > Hi all! > > It might seem strange that you can't easily address the columns with Rank. > > Alignment has a similar irregularity: > > 10 20 +i. 2 3 > 10 11 12 > 23 24 25 > (i. 2 3)+10 20 30 > |length error > | (i.2 3) +10 20 30 > (i. 2 3)+10 20 > 10 11 12 > 23 24 25 > > Common first parts of the argument shapes are aligned. The smaller argument > is then replicated over the remaining dimensions of the larger argument. > > There is no alignment operator which aligns the last parts of the shapes and > replicates over the remaining first dimensions. > > What is even more strange is that problems like these are never resolved. > > A problem you had in IBM APL1 1980 usually remains in J today. > > However, for both these problems, I think they were created with J. In APL1 > I think you wouldn't get the length error above. You could also address > columns. > > I think J is better in both indexing and that you get the same result if you > change the order of the arguments with alignment. However, I think there > could be a way to address the columns. There could be a way to get alignment > along the last dimensions. > > Happily, these problems often cancel each other. What you can't do with > alignment you can do with Rank. > > (i. 2 3)+"1 [10 20 30 > 10 21 32 > 13 24 35 > > Cheers, > > Erling Hellenäs > > > > Den 2017-11-27 kl. 04:21, skrev 'Skip Cave' via Programming: > > Combination of 6 items taken 2 at a time: > > > > comb=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) > > > > |: 2 comb 6 > > > > 0 0 0 0 0 1 1 1 1 2 2 2 3 3 4 > > > > 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5 > > > > > > How can I box each column with the vertical pair of numbers in each box? > > > > > > Skip > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
