Haskell 中的句号、句号或点 (.) 是什么意思?
我真的希望谷歌能够更好地搜索语法:
decades :: (RealFrac a) => a -> a -> [a] -> Array Int Int
decades a b = hist (0,9) . map decade
where decade x = floor ((x - a) * s)
s = 10 / (b - a)
I really wish that Google was better at searching for syntax:
decades :: (RealFrac a) => a -> a -> [a] -> Array Int Int
decades a b = hist (0,9) . map decade
where decade x = floor ((x - a) * s)
s = 10 / (b - a)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
f(g(x))
在
数学中:
f ∘ g
(x)
在 haskell 中:
( f . g )< /代码> <代码>(x)
f(g(x))
is
in mathematics :
f ∘ g
(x)
in haskell :
( f . g )
(x)
意思是函数组合。
请参阅此问题。
另请注意,
fgh x
不等于(fgh) x
,因为它被解释为fg(hx)
,除非进行类型检查(hx) 返回一个函数。这就是 $ 运算符可以派上用场的地方:
fgh $ x
将 x 从作为h
的参数转变为整个表达式的参数。因此它等同于f(g(hx))
并且管道再次工作。It means function composition.
See this question.
Note also the
f.g.h x
is not equivalent to(f.g.h) x
, because it is interpreted asf.g.(h x)
which won't typecheck unless (h x) returns a function.This is where the $ operator can come in handy:
f.g.h $ x
turns x from being a parameter toh
to being a parameter to the whole expression. And so it becomes equivalent tof(g(h x))
and the pipe works again..
是用于函数组合的高阶函数。.
is a higher order function for function composition.“句号是一个函数复合运算符。一般来说,其中 f 和 g 是函数,(f . g) x 与 f (gx) 的含义相同。换句话说,句号用于从函数中获取结果在右侧,将其作为参数提供给左侧的函数,并返回一个表示此计算的新函数。”
"The period is a function composition operator. In general terms, where f and g are functions, (f . g) x means the same as f (g x). In other words, the period is used to take the result from the function on the right, feed it as a parameter to the function on the left, and return a new function that represents this computation."
它是一个函数组合:链接
It is a function composition: link
函数组合(页面比较长,请自行搜索)
Function composition (the page is pretty long, use search)