Skip to content

Instantly share code, notes, and snippets.

@cacharle
Forked from ifukazoo/split.hs
Created August 19, 2019 16:25
Show Gist options
  • Save cacharle/fb0c2a14aa75375a360cb5a5a19ee182 to your computer and use it in GitHub Desktop.
Save cacharle/fb0c2a14aa75375a360cb5a5a19ee182 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