Created
July 6, 2013 14:42
-
-
Save cfr/6ccc186cb78edc5270dd 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
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