Created
January 19, 2019 03:58
-
-
Save agumonkey/82c30e5a20ffae82e636ac45aef579f6 to your computer and use it in GitHub Desktop.
split on change
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
; spart [] = [] | |
; spart [1] = [[1]] | |
; spart [1 1] = [[1 1]] | |
; spart [1 1 2] = [[1 1] [2]] | |
s [] = [] | |
s [x] = [x] | |
s x:xs = sp x:xs x [] [] | |
where sp [] p a r = r | |
sp x:xs p a r = | |
if x = p | |
then sp xs p [x:a] r | |
else sp xs x [x] [a:r] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment