wenduan writes: > I have an IO action up and running in a module I defined > as following:
> 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) Note that are returning 'number' (the unparsed string!) rather than 'n'. So your function's signature is: calculate :: IO [String] That's probably not what you wanted. > Now the question is I couldn't get any clue from the first > three chapters to do the remaining calculation. The simplest solution is to use the standard function from Prelude: http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Asum But I guess writing your own versions won't hurt either. ;-) Peter _______________________________________________ Haskell mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell
