I would rather define:
list = {{1, 3, 5}, {3, 3, 5}, {4, 3, 5}, {5, 3, 5}, {7, 3, 5}};
If you prefer for some reasons your own definition you can use list[[1]]
instead of list
. To extract the first column use First@Transpose@list
or list[[All, 1]]
, for the last column use Last@Transpose@list
, for k-th
column e.g. list[[All, k]]
.
Then there are many ways, let's show a few of them:
Position[ KroneckerDelta /@ (Differences[ First @ Transpose @ list] - 1), 0] + 1
{{2}, {5}}
Instead of mapping KroneckerDelta
we could use simply Unitize
(as pointed out by J.M.), since it is Listable
.
Moreover we could substitute Differences
with subtruction of Rest
and Most
to get the proper result:
Position[ Unitize[ Subtract @@ Through@{Rest, Most}@First@Transpose@list - 1], 1] + 1
another method without Apply
for extracting non-consecutive numbers of the last column:
Position[ Total[ Through @ { Rest, - Most @ # &} @ Last @ Transpose @ list], 0] + 1
{{2}, {3}, {4}, {5}}
A related discussion useful for the problem at hand you can find reading answers to this question Find zero crossing in a list.