Skip to main content
Source Link
ciao
  • 26k
  • 2
  • 61
  • 142

For the second part of question:

(n.b.: If you want positions instead of elements, change #[[Union[p - 1, p]]] to Union[p - 1, p].)

With[{p = Pick[Range@Length@#, Abs[Differences@Prepend[#, #[[1]] - 2]], 1]},
              #[[Union[p - 1, p]]]] &@theList

This will be much faster on larger lists then the solution based on Split from Alexey Popkov (which I up-voted - it's canonical and clean).

Post Made Community Wiki by ciao