Skip to main content
added 205 characters in body
Source Link
E. Chan-López
  • 31.3k
  • 3
  • 29
  • 50
list = {1, -1, 2, 3, 4, 0, -2, 5, 0};

Grabbing the @eldo's pattern and using ReplaceList:

ReplaceList[Split[list, Less], {___, a : {b_, c__} /; b < c, ___} :> a]

{{-1, 2, 3, 4}, {-2, 5}}

Or using Pick:

AscendingSequenceQ[l_] := AllTrue[Differences[l], # > 0 && Length[#] == 1 &]

Pick[#, Not@*AscendingSequenceQ /@ #] &@Split[list, Less]

{{-1, 2, 3, 4}, {-2, 5}}

list = {1, -1, 2, 3, 4, 0, -2, 5, 0};

Grabbing the @eldo's pattern and using ReplaceList:

ReplaceList[Split[list, Less], {___, a : {b_, c__} /; b < c, ___} :> a]

{{-1, 2, 3, 4}, {-2, 5}}

list = {1, -1, 2, 3, 4, 0, -2, 5, 0};

Grabbing the @eldo's pattern and using ReplaceList:

ReplaceList[Split[list, Less], {___, a : {b_, c__} /; b < c, ___} :> a]

{{-1, 2, 3, 4}, {-2, 5}}

Or using Pick:

AscendingSequenceQ[l_] := AllTrue[Differences[l], # > 0 && Length[#] == 1 &]

Pick[#, Not@*AscendingSequenceQ /@ #] &@Split[list, Less]

{{-1, 2, 3, 4}, {-2, 5}}

Source Link
E. Chan-López
  • 31.3k
  • 3
  • 29
  • 50

list = {1, -1, 2, 3, 4, 0, -2, 5, 0};

Grabbing the @eldo's pattern and using ReplaceList:

ReplaceList[Split[list, Less], {___, a : {b_, c__} /; b < c, ___} :> a]

{{-1, 2, 3, 4}, {-2, 5}}