If you do [0.1, 0.2 .. 0.3] it should leave out 0.3. This is floating point numbers and if you don't understand them, then don't use them. The current behaviour of .. for floating point is totally broken, IMO.
On Fri, 2011-09-23 at 11:02 +1200, Richard O'Keefe wrote:In case you meant that as a question, the reason is this:
> I do think that '..' syntax for Float and Double could be useful,
> but the actual definition is such that, well, words fail me.
> [1.0..3.5] => [1.0,2.0,3.0,4.0] ???? Why did anyone ever think
> _that_ was a good idea?
Prelude> [0.1, 0.2 .. 0.3]
[0.1,0.2,0.30000000000000004]
Because of rounding error, an implementation that meets your proposed
law would have left out 0.3 from that sequence, when of course it was
intended to be there. This is messy for the properties you want to
state, but it's almost surely the right thing to do in practice. If the
list is longer, then the most likely way to get it right is to follow
the behavior as currently specified. Of course it's messy, but the
world is a messy place, especially when it comes to floating point
arithmetic.
If you can clear this up with a better explanation of the properties,
great! But if you can't, then we ought to reject the kind of thinking
that would remove useful behavior when it doesn't fit some theoretical
properties that looked nice until you consider the edge cases.
--
Chris
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe