I tried

println [1.0, 1.25..2.0] 

but got

Double is not an instance of Enum

I couldn't find this issue in the "differences to Haskell", though. Is there a recommended alternative?

有帮助吗?

解决方案

You're right that it should be in the "Differences".

For an alternative, consider

iterate :: (a -> a) -> a -> [a]

So, to get your list above, write:

takeWhile (<=2.0) (iterate (+0.25) 1)

It should also be possible to make Double and Float instances of Enum. There is simply lots of work to do in the field of numeric types and type classes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top