3.66 Exercise 3.66
The definition of pairs uses nested interleaving to create pairs (i, j) of increasing i. When i is the highest seen thus far in the stream, the next pair with this value of i will be 2i-1 values ahead; otherwise, it will be 2i ahead.
> (define integer-pairs (pairs integers integers)) > (display-stream (take-stream integer-pairs 25))
(1 1)
(1 2)
(2 2)
(1 3)
(2 3)
(1 4)
(3 3)
(1 5)
(2 4)
(1 6)
(3 4)
(1 7)
(2 5)
(1 8)
(4 4)
(1 9)
(2 6)
(1 10)
(3 5)
(1 11)
(2 7)
(1 12)
(4 5)
(1 13)
(2 8)
'done