And there is "key"
(]/.~2|i.@#)i.8
0 2 4 6
1 3 5 7
which handles the odd case with an easy variant
(</.~2|i.@#)i.9
┌─────────┬───────┐
│0 2 4 6 8│1 3 5 7│
└─────────┴───────┘

On 10/9/2014 7:20 PM, Raul Miller wrote:
I'd probably go with

    i. 8
0 1 2 3 4 5 6 7
    |:_2]\ i.8
0 2 4 6
1 3 5 7

But I see that Bob Therriault has already proposed this mechanism.

You could also do something using selection masks, but I see that Pascal
Jasmin has already proposed something along that line.

So here's another approach:
    (({~ |:@i.) >.@-:@#,2:) i.8
0 2 4 6
1 3 5 7

But that's probably a bit silly.

Thanks,


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to