-
-
Save dminuoso/1dae6372dc8df57e780899759f9156ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Split into strictly monotone slices | |
strictlyMonotone :: Ord a => [a] -> [[a]] | |
strictlyMonotone [] = [] | |
strictlyMonotone (x:xs) = go [x] xs | |
where | |
go buf [] = [] | |
go bs@(b:_) (x:xs) | x > b | |
= go (x:bs) xs | |
| otherwise | |
= reverse bs : go [x] xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment