CS计算机代考程序代写 — CPSC 312 – 2021 – Interactive accumulator

— CPSC 312 – 2021 – Interactive accumulator
— Copyright D. Poole 2021 released under the GPL.

module IOAdder where

— To run it, try:
— ghci
— :load IOAdder
— go

accum n =
do
putStr (“Total ” ++ show n ++ “\nInput an integer (exit with empty line): “)
line <- getLine if (line=="") then return n else accum (n+read line) go = accum 0