OK、それは私がハズケルにはちょうど悪いようですが、私はこれらすべての質問に固執し続けると誓っています。とにかく、私は2つのリストを取って、それらを圧縮し、合計でマップする必要があります。だからここに私がこれまで持っているもので、それが動作していない:ハスケル:地図とジップリスト
zipMapList :: [a] -> [a] -> [a]
zipMapList x y = do
let zipList = zip x y
let mapList = map + zipList
mapList
[OK]を、ここで私は、ファイルをロードしようとしたとき、私は取得していますエラーです:
HW2.hs:18:25: error:
• Couldn't match expected type ‘(a1 -> b) -> [a1] -> [b]’
with actual type ‘[(a, a)]’
• In the second argument of ‘(+)’, namely ‘zipList’
In the expression: map + zipList
In an equation for ‘mapList’: mapList = map + zipList
• Relevant bindings include
mapList :: (a1 -> b) -> [a1] -> [b] (bound at HW2.hs:18:9)
zipList :: [(a, a)] (bound at HW2.hs:17:9)
y :: [a] (bound at HW2.hs:16:14)
x :: [a] (bound at HW2.hs:16:12)
zipMapList :: [a] -> [a] -> [a] (bound at HW2.hs:16:1)
18 | let mapList = map + zipList |
HW2.hs:19:5: error:
• Couldn't match expected type ‘[a]’
with actual type ‘(a0 -> b0) -> [a0] -> [b0]’
• Probable cause: ‘mapList’ is applied to too few arguments
In a stmt of a 'do' block: mapList
In the expression:
do let zipList = zip x y
let mapList = map + zipList
mapList
In an equation for ‘zipMapList’:
zipMapList x y
= do let zipList = ...
let mapList = ...
mapList
• Relevant bindings include
zipList :: [(a, a)] (bound at HW2.hs:17:9)
y :: [a] (bound at HW2.hs:16:14)
x :: [a] (bound at HW2.hs:16:12)
zipMapList :: [a] -> [a] -> [a] (bound at HW2.hs:16:1)
19 | mapList | ^^^^^^^
Iちょうどドンエラーが何を意味するのかを知ると、私はリスト[a]と別のリスト[a]を取得し、それらを圧縮してマップして別のリストを取得することを意味します。なぜタプルエラー誰かが手を貸すことができますか?
"合計でマップする" - それはどういう意味ですか?サンプルの入力と出力を追加できますか? –
[1,2,3] [4,5,6]は[(1,4)、(2,5)、(3,6)]に圧縮され、[5,7,9]にマッピングされます。 –