Streams Quick Review 

Stream = Sequence of values (can be infinite) where each value is not computed until it is forced to (lazy computation, which some of us also use while doing our homework)

(define n (cons-stream 1 (cons-stream 2 n)))

The car of n is 1, but what is the cdr? 2? Some sort of stream? Well, the trick with streams is that the cdr is always a promise. In order to get later values from the stream, you need to call cdr-stream on your stream and force the stream to calculate the next value. If the next value has been forced already (by using cdr-stream, which in the case of n will give us 2) then cdr returns “promise forced”, otherwise, cdr returns “promise not forced.”

Now what about the fact that we used n in our definition of n? How did we not just break computer science? Well, the great thing about lazy computation is that we don’t actually need to know what the third element in our stream is when we define it. Now, if we call (cdr-stream (cdr-stream n)), we’ll get 1, and then the cdr-stream of that is 2, and so on.