Skip to content

Instantly share code, notes, and snippets.

@ifukazoo
Last active August 19, 2019 16:25
Show Gist options
  • Save ifukazoo/0f74739f2a97d31ebe05 to your computer and use it in GitHub Desktop.
Save ifukazoo/0f74739f2a97d31ebe05 to your computer and use it in GitHub Desktop.
split
split :: Eq a => a -> [a] -> [[a]]
split _ [] = [[]]
split delim str =
let (before, remainder) = span (/= delim) str
in before:case remainder of
[] -> []
x -> split delim $ tail x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment