Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell help

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:

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 final

The problem is processing the list to calculate the sum etc. I've tried

let sum = foldr (+) 0 final
  in
    return sum


but it gives me an error. What do I do?

Name: Anonymous 2007-11-18 15:05

Haskell is shit.

/prog/ needs less toy language trolling and more actual discussion about interesting topics.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List