
But Prelude Data.List> [1,1+2/3..4] :: [Double] [1.0,1.6666666666666665,2.333333333333333,2.9999999999999996,3.666666666666666,4.333333333333332] Prelude Data.List> unfoldr (\n -> let n'=n+2/3 in if n' <= 4 then Just (n',n') else Nothing) 1 :: [Double] [1.6666666666666665,2.333333333333333,2.9999999999999996,3.666666666666666] Prelude Data.List> takeWhile (<=4) $ iterate (+2/3) 1 :: [Double] [1.0,1.6666666666666665,2.333333333333333,2.9999999999999996,3.666666666666666] How 'dodgy' it should be to produce different result? How [a,b..c] works in this case?
2010/5/19 Ivan Lazar Miljenovic
: Dmitry Olshansky
writes: Hello all,
It seems that I saw something like this in Cafe recevtly. But I am not sure... In GHC 6.12.1 (Platform 2010 on Windows Vista) I have
Prelude> [1,1+2/3..10] [1.0,1.6666666666666665,2.333333333333333,2.9999999999999996,3.666666666666666,4.333333333333332,4.999999999999998,5.666666666666664,6.33333333333333,6.9999999999999964,7.6666666666666625,8.333333333333329,8.999999999999995,9.66666666666666,10.333333333333327]
-- It is a bug!
No it isn't, because of the dodgy Ord instance for Float and Double values.
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com