I want to do the following, deleting the element of a list that do not match an increasing order as example:
{1,2,3,4,6,5,7,8}->{1,2,3,4,6,7,8}
I've thought of using DeleteCases but I'm not able to specify a criteria for the pattern withing the same list. Any suggestions?
Thanks a lot
Differences
to detect decreasing elements, e.g.Sign /@ Differences@{1, 2, 3, 4, 6, 5, 7, 8}
and then use that to delete elements from the list. $\endgroup${1, 2, 3, 4, 6, 5, 6, 6, 7, 8, 2, 4, 9, 6}
? In any case, see ifPick[#, UnitStep[Differences@Prepend[#, 0] - 1], 1] &@list
orFixedPoint[ Pick[#, UnitStep[Differences@Prepend[#, 0] - 1], 1] &, list]
floats your boat... $\endgroup$