| Paste number 6027: | error in my attempt to use getLine |
| Pasted by: | metaperl |
| When: | 4 years, 4 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+4NF |
| Channel: | #haskell |
| Paste contents: |
module Main
where
import IO
ask_for_numbers = do
hSetBuffering stdin LineBuffering
putStrLn "Enter natural numbers, 0 to stop"
getLine
main =
num <- ask_for_numbers -- <== program fails here
case num of
0 -> []
_ -> num : main
sum = foldr (+) 0
prod = foldr (*) 0
factorial n
| n <= 0 = 1
| n > 0 = n * factorial (n-1)
This paste has no annotations.