Perhaps this is also useful:
ka=:'abcdefghijklmnopqrstuvwxyz'
Ga=:'MNOPQRSTUVWXYZABCDEFGHIJKL'
NB. stretch -- amend -- unstretch (reshape)
($ $"1 ((0 0;0 _1;_1 0 ;_1 _1){($ w),;._3 i. $ i)(,w)"_`[`] }"1 ,) i=.3
3 $ Ga [ w=. 2 2 $ ka
Handles variable 2D shaped arrays AFAICS
Also of course:
w *./@:<&$ i
1
cheers
@@i
On 18-02-19 19:06, Brian Schott wrote:
The snippet below produces a value for r which I would like to produce more
elegantly: without the for. loop suggested by the repeated building of
r-values. Perhaps a gerund-powered amend could work, but I am not
optimistic enough to travel there without some encouragement.
The result in r is attempting to move the array w to each of the 4 corners
of the array i, in turn.
*******snippet below*******
combis =: #:i. 4
w=: 2 2$'abcd'
i=: 3 3$'MNOPQR'
combis<"1@:{2<\i. 3
┌─────────┬─────────┬─────────┬─────────┐
│┌───┬───┐│┌───┬───┐│┌───┬───┐│┌───┬───┐│
││0 1│0 1│││0 1│1 2│││1 2│0 1│││1 2│1 2││
│└───┴───┘│└───┴───┘│└───┴───┘│└───┴───┘│
└─────────┴─────────┴─────────┴─────────┘
]r=:w (<0 1;0 1)}i
abO
cdR
MNO
r=:r,:w (<0 1;1 2)}i
r=:r, w (<1 2;0 1)}i
;/r=:r,w (<1 2;1 2)}i
┌───┬───┬───┬───┐
│abO│Mab│MNO│MNO│
│cdR│Pcd│abR│Pab│
│MNO│MNO│cdO│Mcd│
└───┴───┴───┴───┘
Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm