I'll study Raul's solution a bit more, but in the meantime I think that this is
what you may be looking for:
[combis =: #:i. 4 NB. same definitions as before
0 0
0 1
1 0
1 1
[w=: 2 2$'abcd'
ab
cd
[i=: 3 3$'MNOPQR'
MNO
PQR
MNO
[ind=: combis<"1@:{2<\i. 3 NB. capture the indices that you have selected
┌─────────┬─────────┬─────────┬─────────┐
│┌───┬───┐│┌───┬───┐│┌───┬───┐│┌───┬───┐│
││0 1│0 1│││0 1│1 2│││1 2│0 1│││1 2│1 2││
│└───┴───┘│└───┴───┘│└───┴───┘│└───┴───┘│
└─────────┴─────────┴─────────┴─────────┘
[cmb =: w;i NB. new definition to create a right argument for the (gerund
}) combo
┌──┬───┐
│ab│MNO│
│cd│PQR│
│ │MNO│
└──┴───┘
(<"0 ind) (>@{.@]) `[ ` (>@{:@]) } each <cmb NB. boxing and unboxing is
necessary to keep the arguments lined up. The gerunds act on the x (<"0 ind)
and y (< cmb) to create values for }
┌───┬───┬───┬───┐
│abO│Mab│MNO│MNO│
│cdR│Pcd│abR│Pab│
│MNO│MNO│cdO│Mcd│
└───┴───┴───┴───┘
Cheers, bob
> On Feb 18, 2019, at 10:06 AM, Brian Schott <[email protected]> wrote:
>
> combis<"1@:{2<\i. 3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm