Public feed #380752

Unnamed

public text v1 · immutable
Raw Edit
·published 2007-03-04 08:26 UTC
rendered paste body
module Main
    where

import IO

main = do
  hSetBuffering stdin LineBuffering
  putStrLn "Enter a number (or 0 to end):"
  nums <- getData
  putStrLn ("The sum of all numbers is: " ++ (foldl (+) [0] (nums)))

getData = do
  line <- getLine
  if line == "0"
    then return []
    else do
      rest <- getData
      return ((read line) : (read rest))