我定义了函数 listToNumber 如下:
listToNumber = foldl1 (\acc xs -> acc*10 + xs)
当仅提供一个数字列表时,它可以正常工作,例如:
listToNumber [1,2,3,4] = 1234
map listToNumber [[1,2,3,4], [5,4,3,2]] = [1234,5432]
但是,以下返回错误消息:
map listToNumber permutations[1..3]
有人可以解释一下吗?
PS错误信息如下:
Couldn't match expected type `[t1] -> t0' with actual type `[b0]'
The function `map' is applied to three arguments,
but its type `([b0] -> b0) -> [[b0]] -> [b0]' has only two
In the expression: map listToNumber permutations [1 .. 3]
In an equation for `it':
it = map listToNumber permutations [1 .. 3]