在GHCi中:
- 序曲>(+3)2
5- 序曲>(*3)2
6- 前奏>(/ 3)2
0.6666666666666666- 前奏>( - 3)2
没有实例(Num(t - > t1))
来自文字':it =( - 3)23' at <interactive>:1:2
Possible fix: add an instance declaration for (Num (t -> t1))
In the expression: 3
In the expression: (- 3) 2
In the definition of
如何更正最后一个使其返回-1?
我正在学习使用CIS194(spring13)的Haskell.今天当我试图处理作业4练习1时,我收到了错误
fun1' :: [Integer] -> Integer
fun1' = foldl' (*) 1 . map (-2) . filter even
Run Code Online (Sandbox Code Playgroud)
据说:
error:
? No instance for (Num (Integer -> Integer))
arising from a use of syntactic negation
(maybe you haven't applied a function to enough arguments?)
? In the first argument of map, namely (- 2)
In the first argument of (.), namely map (- 2)
In the second argument of (.), namely map (- 2) . filter even
|
12 | fun1' …Run Code Online (Sandbox Code Playgroud)