You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
606 B
33 lines
606 B
2 years ago
|
|
||
|
Exercise 3.68: Louis Reasoner thinks that
|
||
|
building a stream of pairs from three parts is unnecessarily complicated.
|
||
|
Instead of separating the pair
|
||
|
|
||
|
(
|
||
|
|
||
|
S
|
||
|
0
|
||
|
|
||
|
,
|
||
|
|
||
|
T
|
||
|
0
|
||
|
|
||
|
)
|
||
|
|
||
|
from the rest of the pairs in
|
||
|
the first row, he proposes to work with the whole first row, as follows:
|
||
|
|
||
|
|
||
|
(define (pairs s t)
|
||
|
(interleave
|
||
|
(stream-map
|
||
|
(lambda (x)
|
||
|
(list (stream-car s) x))
|
||
|
t)
|
||
|
(pairs (stream-cdr s)
|
||
|
(stream-cdr t))))
|
||
|
|
||
|
Does this work? Consider what happens if we evaluate (pairs integers
|
||
|
integers) using Louis’s definition of pairs.
|