我需要得到平均值,所以输入停止,直到用户输入一个负数,然后输出是平均值
{
getFloat :: IO Float
getFloat = do line <- getLine
return (read line:: Float)
average :: IO Float
average = helper summ n
where
helper :: Float->Float->IO Float
helper summ n = do val<-getFloat
if (val<0)
then (return average)
else ( do summ = summ + val
n = n+1
average= summ/n
average)
}