Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Created January 19, 2019 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/82c30e5a20ffae82e636ac45aef579f6 to your computer and use it in GitHub Desktop.
Save agumonkey/82c30e5a20ffae82e636ac45aef579f6 to your computer and use it in GitHub Desktop.
split on change
; 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