Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top