在 GHCi 中:
- Prelude> (+3) 2
5- Prelude> (*3) 2
6- Prelude> (/3) 2
0.6666666666666666- Prelude> (-3) 2
No instance for (Num (t -> t1))
arising from the literal3' at <interactive>:1:2
it': it = (- 3) 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?
最佳答案
Haskell 的语法不允许你使用 -
像那样。使用 subtract
代替功能:
(subtract 3) 2
关于haskell - Haskell中一元运算符的前缀形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3406320/