Created
August 25, 2014 03:07
-
-
Save danneu/fa0d6c70f2b806de695c 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
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