> From: Steven Taylor
> Also, for the first row whether rank one or two:
>
> ({:@${.,) i. 3 3
> 0 1 2
>
> ({:@${.,) i. 3
> 0 1 2
>
> NB. select first n items from the ravelled array, where n
> is the last item in the arrays shape
> NB. which is a column (rank 2) or the length of a single
> row (rank 1)
But:
'' -: ({:@$ {. ,) 3
1
Which may or may not be desirable. Here is an alternative:
gfr=: [: {. ,:^:(2 <. 2 - #...@$)
gfr forces y to rank 2 and then takes the first row.
gfr i. 3 3
0 1 2
gfr i. 3
0 1 2
gfr 3
3
gfr i. 3 4 3 3 3
0 1 2
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm