I'm not sure what output you're seeking, so I'll just present a bunch of 
options:

           NB.  Prefix a row of A to each B
           a ,&.> b
        +-----+--------+--------+
        |1 1 1| 2  2  2| 3  3  3|
        |0 1 2| 4  5  6| 7  8  9|
        |3 4 5| 7  8  9|10 11 12|
        |6 7 8|10 11 12|13 14 15|
        +-----+--------+--------+

           NB.  Prefix a col of A to each B
           a ,.&.> b
        +-------+----------+----------+
        |1 0 1 2|2  4  5  6|3  7  8  9|
        |1 3 4 5|2  7  8  9|3 10 11 12|
        |1 6 7 8|2 10 11 12|3 13 14 15|
        +-------+----------+----------+

           NB.  Replace the top row of each B with an A
           a (, }.)&.> b
        +-----+--------+--------+
        |1 1 1| 2  2  2| 3  3  3|
        |3 4 5| 7  8  9|10 11 12|
        |6 7 8|10 11 12|13 14 15|
        +-----+--------+--------+

           NB.  Prefix an A to the first row of each B
           a (}.@:] ,~ [ , {.@:])&.> b
        +-------+----------+----------+
        |1 0 1 2| 2  4  5 6| 3  7  8 9|
        |3 4 5 0| 7  8  9 0|10 11 12 0|
        |6 7 8 0|10 11 12 0|13 14 15 0|
        +-------+----------+----------+

           NB.  Substitute A for the first item of each B
           a (<0;0)}&.> b
        +-----+--------+--------+
        |1 1 2| 2  5  6| 3  8  9|
        |3 4 5| 7  8  9|10 11 12|
        |6 7 8|10 11 12|13 14 15|
        +-----+--------+--------+

           NB.  Same using {. }. [  ]
           a (}.@:] ,~ [ , }.@:{.@:])&.> b
        +-----+--------+--------+
        |1 1 2| 2  5  6| 3  8  9|
        |3 4 5| 7  8  9|10 11 12|
        |6 7 8|10 11 12|13 14 15|
        +-----+--------+--------+
                           
-Dan

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

Reply via email to