Mine wasn't a solution, more of a hint. I got the rank wrong.
That said, the issue you mentioned would break code in just about any
language: my quotes had gotten changed to something else.
Anyways, here's a solution:
(w 2 :'m y}n'i)@<"1(#:i.4){;/+/~0 1
abO
cdR
MNO
Mab
Pcd
MNO
MNO
abR
cdO
MNO
Pab
Mcd
Thanks,
--
Raul
On Mon, Feb 18, 2019 at 4:54 PM 'robert therriault' via Programming
<[email protected]> wrote:
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm