Re: [Jprogramming] Splitting vector

2014-10-09 Thread Linda Alvord
Behalf Of robert therriault Sent: Thursday, October 09, 2014 6:15 PM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Splitting vector Hi Andrey, My first idea is infix, the dyadic mode of \ feeding into monadic transpose |: t=. |: @: (_2 ]\ ]) t 0 1 2 3 4 5 6 7 0 2 4 6 1 3 5 7 Others

Re: [Jprogramming] Splitting vector

2014-10-09 Thread Cliff Reiter
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 ( 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,

Re: [Jprogramming] Splitting vector

2014-10-09 Thread Raul Miller
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 approac

Re: [Jprogramming] Splitting vector

2014-10-09 Thread robert therriault
Hi Andrey, My first idea is infix, the dyadic mode of \ feeding into monadic transpose |: t=. |: @: (_2 ]\ ]) t 0 1 2 3 4 5 6 7 0 2 4 6 1 3 5 7 Others will have more informed feelings about the best way, but this would work. Cheers, bob On Oct 9, 2014, at 3:00 PM, Andrey Paramonov wrot

Re: [Jprogramming] Splitting vector

2014-10-09 Thread 'Pascal Jasmin' via Programming
ot; Cc: Sent: Thursday, October 9, 2014 6:00 PM Subject: [Jprogramming] Splitting vector Hello everyone, What is the best way in J to split a vector into two vectors by even and odd indices? For example, for this input 0 1 2 3 4 5 6 7 I want the following output 0 2 4

[Jprogramming] Splitting vector

2014-10-09 Thread Andrey Paramonov
Hello everyone, What is the best way in J to split a vector into two vectors by even and odd indices? For example, for this input 0 1 2 3 4 5 6 7 I want the following output 0 2 4 6 1 3 5 7 Thank you.