Created
September 12, 2011 14:15
-
-
Save maoe/1211351 to your computer and use it in GitHub Desktop.
chop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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