Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在这个 Haskell 代码中:
power a r = [a*(truncate (r**i)) | i <- e] where e = [0,10]
我的**操作出现错误,因为我相信它会浮动。有没有办法将它转换为int?
**
我不知道您的代码类型检查后出现错误是什么意思,但您可能需要^运算符:
^
(^) :: (Integral b, Num a) => a -> b -> a
您的代码类型检查也很好:
power a r = [a*(r^i) | i <- e] where e = [0,10]