hi all,
I'm new to haskell and just reading the "yet another haskell tutorial".I got stuck on the exercise of chapter 3,the problem goes like "repeatedly prompt the user to input some number until a zero is detected,then output the sum,product of those numbers and the factorial of each number." What I have done is I have an IO action up and running in a module I defined as following:

module Main where
main = do
  calculate

calculate   = do
    putStrLn "Give me a number (or 0 to stop):"
    number <- getLine
    let n = read number
    if n == 0
          then do
             return []
          else do
              rest <- calculate
              return (number : rest)
Now the question is I couldn't get any clue from the first three chapters to do the remaining calculation,what I wanted to do is to get a list out of the IO action I just defined, and do the sum,product and factorial out of the list,I tried something like"list <- calculate, sum list,etc,but it wasn't helpful,so would anyone just give me any hint to solve this,sorry for those who feel its quite basic.

--
-------------------------------------------------------------------------------------------------------
If you didn't succeed at the first attempt, you are just about average.
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to