Skip to content

Instantly share code, notes, and snippets.

@robinp
Created May 21, 2013 21:45
Show Gist options
  • Save robinp/5623525 to your computer and use it in GitHub Desktop.
Save robinp/5623525 to your computer and use it in GitHub Desktop.
isBlank x = ' ' == x
f (lastBlank, res) ch =
if isBlank ch
then (True, if lastBlank then res else ' ':res)
else (False, ch:res)
g s = reverse $ snd $ foldl f (False, []) s
main = print $ g "x y zzz ff dd e"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment