In J
, I have a list like 1 2 3
, I want to take *:
and 2*
to make it a box structure like
┌─┬─┐
│1│2│
│4│4│
│9│6│
└─┴─┘
or even
┌───┐
│1 2│
├───┤
│4 4│
├───┤
│9 6│
└───┘
How to do this? I would really appreciate your help.
You need to evoke a gerund in append mode (:0
).
a =: 1 2 3
*:`+: (`:0) a
1 4 9
2 4 6
If you need them boxed, just ;/
them:
;/*:`+: (`:0) a
┌─────┬─────┐
│1 4 9│2 4 6│
└─────┴─────┘
;/ |: *:`+: (`:0) a NB. different axis
┌───┬───┬───┐
│1 2│4 4│9 6│
└───┴───┴───┘
_3 <\6 1 $,*:`+: (`:0) a NB. yet another axis
┌─┬─┐
│1│2│
│4│4│
│9│6│
└─┴─┘