我正在尝试将双打列表格式化为字符串.我想把一个列表如下:
[0.38, 0.94]
Run Code Online (Sandbox Code Playgroud)
变成这样的东西:
"aString 0.380 0.940"
Run Code Online (Sandbox Code Playgroud)
我试过了:
"aString" ++ map (printf "%7.3f") [0.38, 0.94]
Run Code Online (Sandbox Code Playgroud)
并得到反馈:
<interactive>:80:19:
No instance for (PrintfType Char)
arising from a use of `printf'
Possible fix: add an instance declaration for (PrintfType Char)
In the first argument of `map', namely `(printf "%7.3f")'
In the second argument of `(++)', namely
`map (printf "%7.3f") [0.38, 0.94]'
In the expression: "aString" ++ map (printf "%7.3f") [0.38, 0.94]
Run Code Online (Sandbox Code Playgroud)
我无法解决这个问题.我无法撰写有效的签名.
谢谢