Hello !
I have an problem to which I'd like to find an efficient solution.
Let the vector :
[0, x, x, x, x, 0, x, x, x, 0, x, x, x, x, x]
where x is an unkown integer.
I'd like to extract the first 3 x's starting from each '0'
So I thought about indexing the '0's which gives me something like :
[1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0]
And then use this index to extract groups of value around the '1's
or generate from the previous index another one taking into account the first three 'x's :
[1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0]
But it seems that there is no easy way to do that.
Is there an indexing syntax or a function that would allow me to do that ?
Thank you for your time ~
Best Answer