Thank you.

I eventually did this:

   a ,@,."(0 _) b

Yoel

On Fri, Feb 15, 2008 at 9:18 AM, Chris Burke <[EMAIL PROTECTED]> wrote:
> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to