문제

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