Skip to content

Instantly share code, notes, and snippets.

@danprince
Last active December 28, 2015 13:38
Show Gist options
  • Save danprince/7508684 to your computer and use it in GitHub Desktop.
Save danprince/7508684 to your computer and use it in GitHub Desktop.
71 - Split string by delimiter
-- uncompressed
split str del = foldr (\col ltr ->
if ltr /= del then
(ltr:head col):tail col
else
[]:col) [""] str
-- compressed
x s d = foldl (\c l -> if l/=d then (l:head c):tail c else []:c) [""] s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment