
Alastair Reid:
Ferenc Wagner
writes:
Hmmmm, the CVS copy of Hugs seems to suffer from a different problem:
Prelude> [0.5,1.5..5.5]::[Rational] [0 % 1,1 % 1,2 % 1,3 % 1,4 % 1,5 % 1]
I'm expecting to see:
[1 % 2,3 % 2,5 % 2,7 % 2,9 % 2,11 % 2]
Rationals in Hugs were always a bit obscure. What do you think, what is the Rational form of 2.3 ? (GHCi says 23/10). The answer is: 2589569785738035 % 1125899906842624 (Old Hugs, Feb. 2001) If you look at the Prelude, you will see that the algorithms used for rationals are not always a rocket science. I replaced (for myself) that stuff by the continued fraction expansions which are fast and give decent results. The rational arithmetics can also be optimised by using algorithms in the 2nd volume of Knuth (the favourite book of Ralf Hinze...) I found similar bugs in sequences as above already (if I am not mistaken) about 7 - 8 years ago, when we discussed a bit the usage of Haskell to some numerics. But nobody really cared about it, and it seems that some small but nasty insects are still alive. Jerzy Karczmarczuk