module Bob (responseFor) where import Data.Char ( isSpace, isAlpha, isUpper ) isYelling :: [Char] -> Bool isYelling stmt = any isAlpha stmt && all isUpper (filter isAlpha stmt) isQuestion :: [Char] -> Bool isQuestion stmt = last (filter (not . isSpace) stmt) == '?' responseFor :: String -> String responseFor prompt | all isSpace prompt = "Na gut. Dann eben nicht!" | isQuestion prompt && isYelling prompt = "Chill mal, ich bin da schon dran!" | isQuestion prompt = "Klar." | isYelling prompt = "Whoa, entspann dich!" | otherwise = "Whatever."