3.5.2 Infinite Streams
2024-05-19 Sun

Exercise 3.53

Exercise:

Without running the program, describe the elements of the stream defined by

(define s (cons-stream 1 (add-streams s s)))

Answer:

The elements of the streams are the powers of 2.

s is the list whose car is 1 and whose cdr is the promise to execute (add-stream s s).

Forcing the cdr of s gives us the list whose car is 2 and whose cdr is the promise to execute (add-stream (stream-cdr s) (stream-cdr s)).

Forcing the cdr of the cdr of s gives us the list whose car is 4 and whose cdr

Send me an email for comments.

Created with Emacs 29.3.50 (Org mode 9.6.15)