[Haskell-cafe] strictness and the simple continued fraction

William Lee Irwin III wli at holomorphy.com
Mon Oct 11 23:52:55 EDT 2004


On Mon, Oct 11, 2004 at 09:53:16PM -0400, Scott Turner wrote:
> I tried using continued fractions in a "spiffy lazy list" implementation a 
> while ago. Never got them working as well as expected. 
> Evenutally I realized that calculating with lazy lists is not as
> smooth as you might expect.
> For example, the square root of 2 has a simple representation 
> as a lazy continued fraction, but if you multiply the square root of 2 by 
> itself, your result lazy list will never get anywhere.  The calculation will 
> keep trying to determine whether or not the result is less than 2, this being 
> necessary to find the first number in the representation. But every finite 
> prefix of the square root of 2 leaves uncertainty both below and above, so 
> the determination will never be made.
> Your problems may have some other basis, but I hope this helps.

I hit that one, too. That's nasty enough it may be best to give up on
the infinite case, at least. I can't think of a way to salvage all this.


-- wli


More information about the Haskell-Cafe mailing list