-
-
Save dustinlacewell/06a6cb6e97c9fa70bc0342c36fe1374c to your computer and use it in GitHub Desktop.
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
notThe :: String -> Maybe String | |
notThe s = | |
let p = mkRegex "^[tT][hH][eE]$" | |
in case matchRegex p s of | |
Nothing -> Just s | |
Just o -> Nothing | |
replaceThe :: String -> String | |
replaceThe s = | |
unwords $ Prelude.map (fromMaybe "a" . notThe) (words s) | |
main :: IO () | |
main = do | |
print $ replaceThe "the robin landed on the branch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment