Skip to content

Instantly share code, notes, and snippets.

@kevinadi
Created April 24, 2015 02:02
Show Gist options
  • Save kevinadi/ee3d4a1866c0938e3da7 to your computer and use it in GitHub Desktop.
Save kevinadi/ee3d4a1866c0938e3da7 to your computer and use it in GitHub Desktop.
Haskell: split a string using a char
wordsWhen :: (Char -> Bool) -> String -> [String]
wordsWhen p s = case dropWhile p s of
"" -> []
s' -> w : wordsWhen p s''
where (w, s'') = break p s'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment