相关疑难解决方法(0)

Haskell中一元运算符的前缀形式

在GHCi中:

  1. 序曲>(+3)2
    5
  2. 序曲>(*3)2
    6
  3. 前奏>(/ 3)2
    0.6666666666666666
  4. 前奏>( - 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?

haskell unary-operator ghci prefix-operator

3
推荐指数
2
解决办法
2039
查看次数

在Haskell中的列表上进行映射:约束中的非类型变量参数

let fun1  = (+3)
let fun2  = (-3)
let range = [1,2,3,3]
let a = map fun1 range
let b = map fun2 a
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误:

约束中的非类型变量参数:Num(a - > b)

Haskell的静态性质让我很头疼......

mapping haskell

2
推荐指数
1
解决办法
100
查看次数

标签 统计

haskell ×2

ghci ×1

mapping ×1

prefix-operator ×1

unary-operator ×1