Ah! Thanks. This explains it. Much appreciated

Bob

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Henry Rich
Sent: April 26, 2010 8:52 AM
To: Programming forum
Subject: Re: [Jprogramming] Each and #

You want the entire 1 2 3 4 to be the left operand, but &.> (each) 
doesn't do that, because it is rank 0.  So it 'unboxes' (i. e. passes 
through) the atoms of 1 2 3 4 individually, giving the result you see.

Some ways that work:

(<1 2 3 4) # each <x

1 2 3 4&# each <x

1 2 3 4 <@(#>)"_ 0 <x

Henry Rich

Robert O'Boyle wrote:
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to