or (,~"1 [: i. 1 (_1}) $) a
Henry Rich Devon McCormick wrote: > Like this? > > (],&.|:~[: (]$[:i.*/) [:}:$) a > 0 0 1 > 1 2 3 > > 2 4 5 > 3 6 7 > > (],&.|:~[: (]$[:i.*/) [:}:$) i. 2 3 4 > 0 0 1 2 3 > 1 4 5 6 7 > 2 8 9 10 11 > > 3 12 13 14 15 > 4 16 17 18 19 > 5 20 21 22 23 > > > > On Sat, Jan 30, 2010 at 8:43 PM, David Ward Lambert > <[email protected]>wrote: > >> NB. Write a function to number the rows of its argument. >> NB. Example: `a' is an n-dimensional numerical array. >> ]a =. i.3#2 >> 0 1 >> 2 3 >> >> 4 5 >> 6 7 >> >> NB. NumberRows a >> NB. 0 0 1 >> NB. 1 2 3 >> NB. >> NB. 2 4 5 >> NB. 3 6 7 >> NB. >> NB. I created this pretty length error: (i.*/}:$a),"0 _1 a >> >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
