Another method is to use indexing as in
   /:/:0 0 0 1 0  NB. 1 is where to insert in a 4 element list
0 1 2 4 3
   m=.i.5 5
   b=.0 0 0 1 0 1 0
   (/:/:b){m,2 5$0
 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
 0  0  0  0  0
15 16 17 18 19
 0  0  0  0  0
20 21 22 23 24

The advantage is that you can insert anything (e.g. partial sums)
   (/:/:b){m,2 5$099
 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
99 99 99 99 99
15 16 17 18 19
99 99 99 99 99
20 21 22 23 24

And you can make it work columnwise easily.
/D


      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to