Skip to content

Instantly share code, notes, and snippets.

@devyn
Created January 30, 2011 04:26
Show Gist options
  • Save devyn/802533 to your computer and use it in GitHub Desktop.
Save devyn/802533 to your computer and use it in GitHub Desktop.
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