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?

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top