Name: Anonymous 2007-11-17 15:23
I am supposed to Write a program that will repeatedly ask the user for numbers until she
types in zero, at which point it will tell her the sum of all the numbers, the product of
all the numbers, and, for each number, its factorial.
Here's what I have:
The problem is processing the list to calculate the sum etc. I've tried
but it gives me an error. What do I do?
types in zero, at which point it will tell her the sum of all the numbers, the product of
all the numbers, and, for each number, its factorial.
Here's what I have:
module Main
where
import IO
numbData = do
putStrLn "give numbers"
number <- getLine
if read number == 0
then return []
else do
numbers <- numbData
let final = (number : numbers)
in
return finalThe problem is processing the list to calculate the sum etc. I've tried
let sum = foldr (+) 0 final
in
return sumbut it gives me an error. What do I do?