The verb catenate (,) has infinite rank, but to emulate outer product in APL, you need catenate to be applied with rank 0 (scalars) … you can use rank to help out here … ,”0
a,"0/b 0 0 0 1 0 2 0 3 1 0 1 1 1 2 1 3 2 0 2 1 2 2 2 3 (the above has shape 3 4 2, which is shape 3 4 of the pairs as per APL). or you can also use <each>, defined as: each &.> which applies disclose (>) a rank 0 function, to each cell before catenating, then applies the inverse (enclose) so now you see more what you expected in APL: a ,each/ b ┌───┬───┬───┬───┐ │0 0│0 1│0 2│0 3│ ├───┼───┼───┼───┤ │1 0│1 1│1 2│1 3│ ├───┼───┼───┼───┤ │2 0│2 1│2 2│2 3│ └───┴───┴───┴───┘ (the above may not print well, but is a 3 4 array of enclosed pairs of indices as per the APL outer product). Also a useful link to view on this: http://www.jsoftware.com/papers/aplj.pdf <ttp://www.jsoftware.com/papers/aplj.pdf> Hope this helps Gian, Rob > On 2 Apr 2016, at 6:11 PM, Gian Medri <[email protected]> wrote: > > Hi ! > > In J the outer product has the form: a foo/ b. > It doesn't work for comma. > Example > a=: i. 3 > b=: i.4 > [ a ,/ b > 0 1 2 0 1 2 3 > APL > a °. , b > 0 0 0 1 0 2 0 3 > 1 0 1 1 1 2 1 3 > 2 0 2 1 2 2 2 3 > > 3 x 4 boxed result > > Can I have the same result in J as easily as in APL? > Best regards > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
