Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Bob (responseFor) where
- import Data.Char
- responseForNothing = "Fine. Be that way!"
- responseForYelledQuestion = "Calm down, I know what I'm doing!"
- responseForShout = "Whoa, chill out!"
- responseForQuestion = "Sure."
- responseForAnythingElse = "Whatever."
- isQuestion xs = last xs == '?'
- responseForShouting :: String -> String
- responseForShouting xs
- | isQuestion xs = responseForYelledQuestion
- | otherwise = responseForShout
- responseFor :: String -> String
- responseFor xs
- | (null . filter isAlphaNum) xs = responseForNothing
- | (all isUpper && null) (filter isAlpha xs) = responseForShouting xs
- | isQuestion xs = responseForQuestion
- | otherwise = responseForAnythingElse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement