小编JDH*_*ope的帖子

"foldl1(\ ab - >(snd a + snd b))[(1,2),(3,4)]的Haskell错误

为什么这不起作用?

Prelude> foldl1 (\a b -> ((snd a) + (snd b))) [(1,2),(3,4)]

<interactive>:1:17:
    Occurs check: cannot construct the infinite type: b = (a, b)
      Expected type: (a, b)
      Inferred type: b
    In the expression: ((snd a) + (snd b))
    In the first argument of `foldl1', namely
        `(\ a b -> ((snd a) + (snd b)))'
Run Code Online (Sandbox Code Playgroud)

haskell

3
推荐指数
1
解决办法
176
查看次数

标签 统计

haskell ×1