Skip to content

Instantly share code, notes, and snippets.

@cfr
Created July 6, 2013 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfr/6ccc186cb78edc5270dd to your computer and use it in GitHub Desktop.
Save cfr/6ccc186cb78edc5270dd to your computer and use it in GitHub Desktop.
import System.Random (randomRIO)
replies = ["Yes", "Signs point to yes", "It is certain", "It is decidedly so", "Without a doubt"
, "Yes, definitely", "You may rely on it", "As I see it yes", "Most likely", "Outlook good"
, "Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now"
, "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no"
, "Outlook not so good", "Very doubtful"]
randomElem [] = error "Empty list"
randomElem xs = randomRIO (0, length xs - 1) >>= return . (xs !!)
main = do
putStrLn "Type 'Exit' to end the program."
putStrLn "Ask A Question: "
u <- getLine
if (u `elem` ["Exit", "exit"]) then return ()
else randomElem replies >>= putStrLn >> main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment