I have a list of numbers and I am looking for a way to most efficiently find positions of values that satisfy a certain condition and group those positions that are sequential. To illustrate, a simple list can look like
and I am interested in all numbers that are greater than 2 and so I expect the return to look like:
Alternatively, I would also need the result being the values in
x however grouped in the same manner.
The stress is also on effectivness, this will be applied on a number of 100 MB data files.
My initial idea was:
Position[x, n_ /; n > 50] // Flatten
and then somehow go through the output and determined if the next position is previous plus 1 but I think this is not very effective (also I have no idea how to do it without complex loops).