【发布时间】:2012-05-07 21:47:44
【问题描述】:
我对 Haskell 比较陌生,如果我的问题听起来很愚蠢,我深表歉意。我一直在尝试了解函数组合的工作原理,并且遇到了一个我想知道有人可以帮助我解决的问题。我在以下两种情况下在函数组合中使用 map:
map (*2) . filter even [1,2,3,4]map (*2) . zipWith max [1,2] [4,5]
虽然 filter 和 zipWith 函数都返回一个列表,但只有第一个组合有效,而第二个组合抛出以下错误:
"Couldn't match expected type '[Int] -> [Int]' with actual type '[c0]'
任何建议将不胜感激。
【问题讨论】:
-
回答this question 有帮助吗? (特别是this one)
-
第一个实际产生输出
Couldn't match expected type a0 -> [b0]' with actual type [a1]'
标签: haskell syntax map function-composition