Just need a little help with the GatherBy
/ SplitBy
function(s).
I have a list of random numbers here:
{8, 4, 2, 1, 9, 4, 2, 1, 5, 2, 1, 3, 1, 2, 11, 4, 2, 1, 5, 2, 1, 3, \
1, 2, 7, 2, 1, 3, 1, 2, 5, 1, 2, 4, 15, 4, 2, 1, 5, 2, 1, 3, 1, 2, 7, \
2, 1, 3, 1, 2, 5, 1, 2, 4, 11, 2, 1, 3, 1, 2, 5, 1, 2, 4, 9, 1, 2, 4,
8}
How can I write a function with a look-ahead? I want to gather the numbers so it splits whenever it the next number is larger than the current one? (spaced for clarity):
{{8, 4, 2, 1},
{9, 4, 2, 1},
{5, 2, 1},
{3, 1},
{2},
{11, 4, 2, 1},
...}
Tried and failed:
SplitBy[%, Greater]