为什么这个函数不能计算整数列表的平均值?平均值、整数、函数、列表

2023-09-04 01:33:19 作者:一切随风

我正在尝试创建一个函数,该函数将给定列表中的所有数字相加,然后将其除以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

推荐答案

excel 函数计算问题

您需要在quot两边加上反号,或者先写

sum m `quot` 6
quot (sum m) 6