Skip to content

Instantly share code, notes, and snippets.

@danneu

danneu/game1.hs

Created Aug 25, 2014
Embed
What would you like to do?
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
You can’t perform that action at this time.