我是一个试图学习哈斯克尔的新手,我试图寻找类似的东西在其他论坛,但无法找到类似的问题。哈希克尔currying删除参数变量在最后
addPoly :: (Num a)=>[[a]]->[a]
addPoly x = map sum $ transpose x
运行正常
,但是当我在最后它的错误删除X出来
addPoly :: (Num a)=>[[a]]->[a]
addPoly = map sum $ transpose
错误说:
Couldn't match expected type `[[Integer]] -> [Integer]'
with actual type `[Integer]'
In the expression: map sum $ transpose
In an equation for `addPoly': addPoly = map sum $ transpose
Couldn't match expected type `[[Integer]]'
with actual type `[[a0]] -> [[a0]]'
In the second argument of `($)', namely `transpose'
In the expression: map sum $ transpose
In an equation for `addPoly': addPoly = map sum $ transpose
无法弄清楚,我错过了什么这里。
免责声明:这不是一门功课问题
我会补充一点,在删除参数时的一般经验法则是将'$'s改为'.'s。显然,这在每种情况下都不起作用,但对于模式'f x = g1 $ g2 $ g3 $ g4 x',您可以将其重写为'f = g1。 g2。 g3。 g4' – bheklilr