Skip to content

Instantly share code, notes, and snippets.

@maoe
Created September 12, 2011 14:15
Show Gist options
  • Save maoe/1211351 to your computer and use it in GitHub Desktop.
Save maoe/1211351 to your computer and use it in GitHub Desktop.
chop
import Data.Char (isSpace)
import Data.Maybe (fromMaybe)
chop :: String -> String
chop = fromMaybe "" . foldr go Nothing
where
go c Nothing
| isSpace c = Nothing
| otherwise = Just [c]
go c (Just xs) = Just (c:xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment