|
defines the stream of values 1 2 3 repeating infinitely. It's not hard to define a recursive procedure that, given an arbitrarily long list, creates the stream repeating it infinitely. Given the repetition, you can always cons-stream more nonrepeating stuff on the head.
But I don't recommend finding the repeating part of the expansion of a rational explicitly, and then using this technique. It's easier to define a recursive procedure that produces the whole stream uniformly, without noticing explicitly that it repeats. The general form is The first ??? is some expression that uses the variables n1 ... ni to describe the first element in the stream. The second ??? is a sequence of expressons to describe the arguments to sfn that produce the remainder of the stream.
For Mike O'D. |
to: