Continued fraction/Arithmetic/Construct from rational number: Difference between revisions

m
Line 295:
I found the reference to "lazy evaluation" misleading, for it implies a special feature of a programming language. Haskell, for example, evaluates lists "lazily". ATS has the notation '''$delay''', and there are various "lazy list" implementations for Scheme. I considered using such methods, but decided against doing so.
 
What one is--I am certain--supposed to write is means for generating an arbitrary number of terms of a continued fraction, one term after another. It happens that, for a rational number, eventually all further terms are known to be swamped by an infinity, and so need not be computed. The significant (finite-valued) terms ''could'' be returned as a finite-length list. However, this will not be so when irrational numbers enter the picture. Therefore one needs a way to generate ''an indefinite number'' of terms. But this is something that requires no "lazy" features of a language. It could be done easily in standard C! The resulting code might, indeed, evaluate terms "lazily", but no special language features are required.
 
So I do not use '''$delay''' at all. I do use closures, which standard C does not have, but pairing a regular procedure with an environment could achieve the same effect in C. (Indeed, the ATS compiler implements closures by generating such C code.)
1,448

edits