[Haskell-cafe] Why does [1.0, 3 ..4] contain 5?
Silvio Frischknecht
silvio.frischi at gmail.com
Wed Oct 19 19:16:49 UTC 2016
Hi,
I don't claim to know the real reason. But I can see that it would make
some things more stable or rather it makes the stable versions look nicer.
[1,1.1 .. 2] looks better than
[1,1.1 .. 2.05]
If you define it like you suggest
numericEnumFromThenTo e1 e2 e3 = takeWhile (<=e1) [e2, e3 ..] :: [Float]
I get
length $ numericEnumFromThenTo 1 1.1 2 === 10
length $ numericEnumFromThenTo 2 1.2 3 === 11
Cheers,
Silvio
More information about the Haskell-Cafe
mailing list