Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Content added Content deleted
Line 297: | Line 297: | ||
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 finite 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. |
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 finite 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. |
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.) |
||
<hr/> |
<hr/> |