How to pick increasing numbers from the list.
lst = {5, 3, 6, 2, 7, 4, 8};
out:
{5,6,7,8}
So many interesting answers, is it possible know the index of result elements or position of elements with respect to the old "lst"?
Answer
Just to be different:
Block[{i = -∞}, Select[lst, # > i && (i = #) == i &]]
Note: Alexey Popkov points out that this solution relies on Select
testing each element in turn from left to right, which is not documented.
Comments
Post a Comment