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

Line 295:
The task is vague about how the "lazy evaluation" works, and it seems to me a function with side effects suffices. Nevertheless, what I did was write such a function that has side effects, and then wrap that function in a thunk (a closure taking no arguments). One might wish to go farther and produce a lazy stream, but I did not do that.
 
I hope the point is not that one must use lazy evaluation to do this algorithm! That wouldis beggetting theinto questionprogramming oflanguage whatfeatures "lazyrather evaluation"than meansproblem-solving. Rather, the point seems to write ''some'' method of producing the digits of the continued fraction. ''This process itself''--of producing "digits" of a continued fraction--will be regarded as the value of the number. For a rational number, the process terminates; for an irrational number, it does not.
 
(I have, by the way, long viewed "a real number" as such a process. It does not matter whether or not the process involves continued fractions, as long as it produces an arbitrarily precise rational number.)
1,448

edits