Elias Mårtenson <[email protected]> wrote:
> Assume I have a binary sequence. Say, something like this:
>
> 0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1
>
> Here, we can see a few sequences of consecutive ones. I want to zero out
> every second in each sequence. I.e, I'd like to get the following result:
>
> 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1
Not sure if it is short enough, but this seems to work;
however I suggest you check it carefully:
V×2|+\1⌈(⍳⍴V)×2|⊤\2+V
V ← 0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1
V×2|+\1⌈(⍳⍴V)×2|⊤\2+V
0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1
Regards,
--
Thomas Baruchel