Hi 

 

I have a matrix, x, which is boxed

 

   x=. i. 4 6

    <x

------------------┐

│ 0  1  2  3  4  5│

│ 6  7  8  9 10 11│

│12 13 14 15 16 17│

│18 19 20 21 22 23│

L------------------

I want to copy each row of x. Using #, I can do this on the unboxed x matrix

 

   1 2 3 4 #"2 x

 

 0  1  2  3  4  5

 6  7  8  9 10 11

 6  7  8  9 10 11

12 13 14 15 16 17

12 13 14 15 16 17

12 13 14 15 16 17

18 19 20 21 22 23

18 19 20 21 22 23

18 19 20 21 22 23

18 19 20 21 22 23

 

But I get an unexpected result when I use the verb 'each'.

 

1 2 3 4 #"2 each <x

------------------T-----------------T-----------------T-----------------┐

│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│

│ 6  7  8  9 10 11│ 0  1  2  3  4  5│ 0  1  2  3  4  5│ 0  1  2  3  4  5│

│12 13 14 15 16 17│ 6  7  8  9 10 11│ 0  1  2  3  4  5│ 0  1  2  3  4  5│

│18 19 20 21 22 23│ 6  7  8  9 10 11│ 6  7  8  9 10 11│ 0  1  2  3  4  5│

│                 │12 13 14 15 16 17│ 6  7  8  9 10 11│ 6  7  8  9 10 11│

│                 │12 13 14 15 16 17│ 6  7  8  9 10 11│ 6  7  8  9 10 11│

│                 │18 19 20 21 22 23│12 13 14 15 16 17│ 6  7  8  9 10 11│

│                 │18 19 20 21 22 23│12 13 14 15 16 17│ 6  7  8  9 10 11│

│                 │                 │12 13 14 15 16 17│12 13 14 15 16 17│

│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│

│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│

│                 │                 │18 19 20 21 22 23│12 13 14 15 16 17│

│                 │                 │                 │18 19 20 21 22 23│

│                 │                 │                 │18 19 20 21 22 23│

│                 │                 │                 │18 19 20 21 22 23│

│                 │                 │                 │18 19 20 21 22 23│

L-----------------+-----------------+-----------------+------------------

   

Any assistance on this would be appreciated.

 

Bob

 

 

 

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

Reply via email to