Skip to content

Instantly share code, notes, and snippets.

@danneu
Created August 25, 2014 03:07
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 danneu/fa0d6c70f2b806de695c to your computer and use it in GitHub Desktop.
Save danneu/fa0d6c70f2b806de695c to your computer and use it in GitHub Desktop.
main :: IO ()
main = do
runGame []
runGame :: [Integer] -> IO ()
runGame nums = do
putStrLn "Give me a number (or 0 to stop):"
inputStr <- getLine
let inputNum = (read inputStr) :: Integer
if inputNum == 0
then putStrLn $ "Sum: " ++ (show . sum) nums
else runGame $ inputNum:nums
-- *Main System.Random> main
-- Give me a number (or 0 to stop):
-- 6
-- Give me a number (or 0 to stop):
-- 2
-- Give me a number (or 0 to stop):
-- 0
-- Sum: 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment