Rational sequence

Simon Peyton-Jones simonpj@microsoft.com
Tue, 22 Oct 2002 12:11:36 +0100


The Report says that the Enum instance for Ratio uses the same rule as
for Float/Double, namely that=20
	[a..b]
means
	takeWhile (<=3D (b+1/2)) [a, a+1, a+2, ...]

You may say that the "<=3D" should be "<" but that's what the Report =
says.
Certainly if you do [1%3..10%3] you'll get more values than your rule
suggests. =20

I'm not sure what your rule should be, though.  (What about [2%4, ...
20%4]?)
Anyway, it's a bit late to change the Report

Simon

| -----Original Message-----
| From: Ferenc Wagner [mailto:wferi@bolyai1.elte.hu]
| Sent: 22 October 2002 11:12
| To: haskell-cafe@haskell.org
| Subject: Rational sequence
|=20
| With GHC-5.02.2, I do
|=20
| $ ghci
| Prelude> :m Ratio
| Ratio> [1%2..10%2]
| [1 % 2,3 % 2,5 % 2,7 % 2,9 % 2,11 % 2]
|=20
| The question is, why is there 11%2 at the end of the list?
| It's inconsistent with the (good) rules for Integer, since
|=20
| Ratio> [1,3..10]
| [1,3,5,7,9]
|=20
| Is this intentional?
|                                         Feri.
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe