为什么这个函数不能计算整数列表的平均值? [英] Why isn't this function to calculate the average of an integer list not working?
本文介绍了为什么这个函数不能计算整数列表的平均值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个函数,该函数将给定列表中的所有数字相加,然后将其除以6。
average :: [Integer] -> Integer
average m = (sum m) quot 6
但这是我收到的错误消息:
Couldn't match type `Integer'
with `(a0 -> a0 -> a0) -> a1 -> Integer'
Expected type: [(a0 -> a0 -> a0) -> a1 -> Integer]
Actual type: [Integer]
In the first argument of `sum', namely `m'
In the expression: (sum m) quot 6
推荐答案
您需要在quot
两边加上反号,或者先写
sum m `quot` 6
quot (sum m) 6
这篇关于为什么这个函数不能计算整数列表的平均值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文