I am trying to do following:
10 ** length xs * x
but I get:
No instance for (Floating Int) ar开发者_JAVA技巧ising from a use of `**'
You can use ^
to raise to an integral power. There's no need to convert to float here.
Besides @sepp2k's answer, if you somehow really need to convert from an integer to some other types of Num, use fromIntegral
.
-- # fromIntegral :: (Integral a, Num b) => a -> b
10 ** fromIntegral (length xs) * x
精彩评论