伙计们请告诉我为什么这不是编译
putStrLn("The average number of fans for the films of " ++ actor ++ " is : " ++ printf "%.2f\n" (show(countAveFans actor testDatabase))
它很简单,但我不能想为什么它不起作用。我尝试将整个事物转换为字符串并打印出2小数点。谢谢
答案 0 :(得分:7)
您需要向RealFloat
提供String
而不是printf
,因此请取消对show
的调用:
putStrLn $ "The average number of fans for the films of " ++ actor ++ " is : " ++ (printf "%.2f\n" $ countAveFans actor testDatabase)