関数 listToNumber を次のように定義しました。
listToNumber = foldl1 (\acc xs -> acc*10 + xs)
数値リストが 1 つだけ指定されている場合は問題なく動作します。たとえば、次のようになります。
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]