![函数 函数](https://c1.lmlphp.com/image/static/default_avatar.gif)
本文介绍了Haskell(。)用于具有多个操作数的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述 (。)
操作符具有签名:
( 。)::(b - > c) - > (a - > b) - > a - > c
(。)fgx = f $ gx
这看起来有点类似于 g 组合函数 / em>。
我对扩展 g 函数的数量不感兴趣,但是(一些)函数适用于(。)
函数带有多个操作数的函数 g
。换句话说就像这样:
(..)::(c - > d) - > (a→b→c)→> a - > b - > d
(..)fgxy = f $ gxy
搜索不会导致任何功能。是否有一个包可以处理这个任意数量的操作数? 解决方案
回答 - 如果我的评论:
多参数函数组合运算符很容易定义,幸运的是某人已经为您做了这个。 包中有一组不错的操作符让你用这种方式来编写功能。我还发现,不是使用haskell.org的hoogle引擎,而是使用版本搜索更多的软件包使得它更容易找到我要找的东西。
The (.)
operator has the signature:
(.) :: (b -> c) -> (a -> b) -> a -> c
(.) f g x = f $ g x
This looks a bit similar to the composition function in primitive recursive functions with one g.
I'm not interested in extending the number of g-functions, but (a number of) functions that apply the (.)
function on a function g
with multiple operands. In other words something like:
(..) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(..) f g x y = f $ g x y
A search on Hoogle doesn't result in any function. Is there a package that can handle this with an arbitrary number of operands?
解决方案
To answer-ify my comments:
Multi-argument function composition operators are very easy to define, and luckily someone has done this for you already. The composition package has a nice set of operators for you to use to compose functions in this manner. I also find that instead of using haskell.org's hoogle engine, fpcomplete's version searches through more packages making it easier to find what I'm looking for.
这篇关于Haskell(。)用于具有多个操作数的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!