小编xma*_*thx的帖子

使用 lambda 表达式进行组合 haskell

我尝试使用组合与 lambda 表达式的虚拟示例。下面的代码可以编译,但当我尝试时它不会运行(f.g) 3 2

f x = x^2
g x = 5*x

f.g = \x -> f(g x)
    
Run Code Online (Sandbox Code Playgroud)

它给出了这样的错误:

Ambiguous occurrence `.'
It could refer to
   either `Prelude..',
          imported from `Prelude' at list3.hs:1:1
          (and originally defined in `GHC.Base')
       or `Main..', defined at list3.hs:42:3.
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我问题出在哪里吗?

lambda haskell composition

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

标签 统计

composition ×1

haskell ×1

lambda ×1