我正在尝试使用.运算符编写一个函数,它接受三个值并返回它们的最大值.
显然,以下工作
max3 a b c = max a (max b c)
max3 a b c = max a $ max b c
Run Code Online (Sandbox Code Playgroud)
但我想用..我试过了
max3 a b c = max a . max b c
Run Code Online (Sandbox Code Playgroud)
但得到错误
Couldn't match expected type `a0 -> Float' with actual type `Float'
In the first argument of `max', namely `b'
Run Code Online (Sandbox Code Playgroud)
我知道这个例子很愚蠢,但对正确的方法做了很好的解释,为什么会非常感激.
haskell ×1