Created
January 30, 2011 04:26
-
-
Save devyn/802533 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
main = interact prg | |
prg :: String -> String -- pure function! | |
prg s = unlines $ [ "What is your name?" | |
, "Hi, " ++ name ++ "!" | |
, "Where do you live?" | |
, place ++ " is very nice, isn't it?" ] | |
++ re 2 (lns !! 2) | |
where lns = lines s | |
name = lns !! 0 | |
place = lns !! 1 | |
re c "yes" = [ "I thought so!" | |
, "Goodbye, " ++ name ++ "!" ] | |
re c "no" = [ "Oh, that's unfortunate." | |
, "Anyway, " ++ name ++ ", ja mata ne!" ] | |
re c _ = [ "Please answer \"yes\" or \"no\". Let me ask again: isn't it??" ] | |
++ re (c+1) (lns !! (c+1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment