具有反向语法的功能组成

发布于 2025-01-29 21:48:43 字数 325 浏览 2 评论 0原文

如果我想先应用f首先和g第二,我必须写:

g . f

是否有另一种标准语法可以让我以相反的顺序编写功能?

f <whatever> g

我知道我只能发明自己的语法:

compose f g x = g (f x)

然后这样使用它:

f `compose` g

但是我宁愿使用标准的图书馆设施。

If I want to apply f first and g second, I have to write:

g . f

Is there another standard syntax that would allow me to write the functions in the reverse order?

f <whatever> g

I know I can just invent my own syntax:

compose f g x = g (f x)

and then use it like this:

f `compose` g

But I would rather use a standard library facility.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似最初 2025-02-05 21:48:43

f&gt;&gt;&gt; g来自 control.arrow

f >>> g from Control.Arrow.

弥繁 2025-02-05 21:48:43

此外, &gt>&gt;&gt;&gt;&gt;,某些库提供了他们自己的此功能的版本,例如:

  • compose。 .html#V:组成“ rel =” nofollow noreferrer“> flow 。
  • - 。来自 coptosing-prelude

您可以使用 hoogle 找到具有特定签名的函数示例。对于确切的问题,您可以使用 hoogle.haskell.org/?hoogle =(a - &gt; b) - &gt; (b - &gt; c) - &gt; (a - &gt; c)

In addtition to >>>, some libraries provide their own version of this function, for example:

You may use Hoogle to find examples of functions with a specific signature. For your exact question you can use hoogle.haskell.org/?hoogle=(a -> b) -> (b -> c) -> (a -> c).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文