Sha256: 5714331fb72195354a861e642d5466c410487458f23898f18bc320e3d84e8c7e

Contents?: true

Size: 583 Bytes

Versions: 293

Compression:

Stored size: 583 Bytes

Contents

module Bob (responseFor) where
import Data.Char (isSpace, isUpper, isAlpha)

data Prompt = Silence | Yell | Question | Other

classify :: String -> Prompt
classify s | all isSpace s = Silence
           | any isAlpha s && all isUpper (filter isAlpha s) = Yell
           | '?' == last (filter (not . isSpace) s) = Question
           | otherwise = Other

response :: Prompt -> String
response Silence = "Fine. Be that way!"
response Yell = "Whoa, chill out!"
response Question = "Sure."
response Other = "Whatever."

responseFor :: String -> String
responseFor = response . classify

Version data entries

293 entries across 293 versions & 1 rubygems

Version Path
trackler-2.2.1.75 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.74 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.73 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.72 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.71 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.70 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.69 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.68 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.67 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.66 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.65 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.64 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.63 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.62 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.61 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.60 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.59 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.58 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.57 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs
trackler-2.2.1.56 tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs