Yoel Jacobsen wrote:
How can I append each element of the RHS list to each element of the LHS list?
Example:
a =. 1 2 3
b =. 10 20 30
I would like a to achieve: a <something> b that will result in:
1 10 1 20 1 30
2 10 2 20 2 30
3 10 3 20 3 30
If you append each element of the RHS to each element of the LHS using
,"0/ then the result will be an array of shape ($LHS),($RHS),2. So you
need an extra step to flatten this to a matrix. You can also use catalog.
For example:
f=. ;"2@(,"0/)
g=. ;"[EMAIL PROTECTED]@;
1 2 3 f 10 20 30 40
1 10 1 20 1 30 1 40
2 10 2 20 2 30 2 40
3 10 3 20 3 30 3 40
1 2 3 g 10 20 30 40
1 10 1 20 1 30 1 40
2 10 2 20 2 30 2 40
3 10 3 20 3 30 3 40
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm