我试图理解为什么这两个评估:(init . cuts) [1,2,3]
并且init . cuts [1,2,3]
是不同的,其中:
cuts :: [a] -> [([a],[a])]
cuts xs = zipWith splitAt [0..length xs] (repeat xs)
第一个给出了我期望的结果:[([],[1,2,3]),([1],[2,3]),([1,2],[3])],但是第二个返回此错误:
<interactive>:389:8:
Couldn't match expected type `a0 -> [a1]'
with actual type `[([a2], [a2])]'
In the return type of a call of `cuts'
Probable cause: `cuts' is applied to too many arguments
In the second argument of `(.)', namely `cuts [1, 2, 3]'
In the expression: init . cuts [1, 2, 3]
我假设,init . cuts [1,2,3] = init (cuts[1,2,3])
这是正确的吗?
谢谢,
塞巴斯蒂安。