map
関数を理解しているかどうかを確認するための練習として、A〜Zの範囲のすべての項目にchar 'a'を追加したいと考えました。私は出力としてundestandいけないこれらの例外を取得するためリスト内のすべての項目にcharを追加するにはどうすればよいですか?
まあappearently私はいけない:
Prelude> map (++ 'A')['A'..'Z']
<interactive>:46:9:
Couldn't match expected type ‘[a]’ with actual type ‘Char’
Relevant bindings include it :: [[a]] (bound at <interactive>:46:1)
In the second argument of ‘(++)’, namely ‘'A'’
In the first argument of ‘map’, namely ‘(++ 'A')’
In the expression: map (++ 'A') ['A' .. 'Z']
<interactive>:46:14:
Couldn't match expected type ‘[a]’ with actual type ‘Char’
Relevant bindings include it :: [[a]] (bound at <interactive>:46:1)
In the expression: 'A'
In the second argument of ‘map’, namely ‘['A' .. 'Z']’
In the expression: map (++ 'A') ['A' .. 'Z']
<interactive>:46:19:
Couldn't match expected type ‘[a]’ with actual type ‘Char’
Relevant bindings include it :: [[a]] (bound at <interactive>:46:1)
In the expression: 'Z'
In the second argument of ‘map’, namely ‘['A' .. 'Z']’
In the expression: map (++ 'A') ['A' .. 'Z']
Prelude>
私は++が文字列が含まれるリストの連結演算子であることを理解します。
私のコードで何が間違っていますか?
。多分あなたは文字列を使うことを意図していました。二重引用符を使用してください。 –