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.
我试过了
println [1.0, 1.25..2.0]
但得到了
Double is not an instance of Enum
不过,我在“与 Haskell 的差异”中找不到这个问题。有推荐的替代品吗?
你是对的,它应该在“差异”中。
作为替代方案,请考虑
iterate :: (a -> a) -> a -> [a]
因此,要获得上面的列表,请写:
takeWhile (<=2.0) (iterate (+0.25) 1)
Double也应该可以Float制作Enum. 在数值类型和类型类领域有很多工作要做。
Double
Float
Enum