相当于OCAML中的Haskell $ $ operator
OCAML中的Haskell的$
运算符等效吗?还是我必须依靠支架?例如,请
multiplyByFive 5 + 1 -- 26
参见
multiplyByFive $ 5 + 1 -- 30
Is there an equivalent to Haskell's $
operator in OCaml, or do I have to rely on brackets? See for example,
multiplyByFive 5 + 1 -- 26
but
multiplyByFive $ 5 + 1 -- 30
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
标准库同时定义了左侧的应用程序操作员
@@
和左右应用程序操作员
|>
:具有预期的关联性(适合
@@ ,为
|>
左右。The standard library defines both a right-to-left application operator
@@
and left-to-right application operator
|>
:with the expected associativity (right for
@@
and left for|>
).您正在寻找
@@
You're looking for
@@
在OCAML中,您可以使用应用程序操作员(在OCAML 4.01中添加)实现相同的操作。
应用程序操作员具有正确的优先级,因此首先评估操作员的右侧,类似于Haskell的应用程序操作员($)。您可能还想查看OCAML中的管道操作员(|>),这是类似于Haskell中(&)运算符的反向应用程序操作员。
In OCaml, you can use the application operator (added in OCaml 4.01) to achieve the same.
The application operator carries right precedence so the right side of the operator is evaluated first, similar to Haskell's application operator ($). You might also want to look into the pipeline operator (|>) in OCaml which is a reverse application operator similar to the (&) operator in Haskell.