Chapter 3, Modularity, Objects, and State

Exercise 3.76


1
2
3
4
5
6
7
(define (smooth s)
  (stream-map
    (lambda (last-value curr-value)
	  (/ (+ last-value curr-value) 2))
	s
	(stream-cdr s)
	))

Now, Louis code in ex-3.75 is not needed. We just need this line modified in the Alyssa’s code in ex-3.74:

1
(define zero-crossings (make-zero-crossings (smooth sense-data) 0))

Or in the suggestion given by Eva Lu Ator in ex-3.74, we just need to do the following:

1
2
3
(define zero-crossings
  (let ((smoothed (smooth sense-data)))
	(stream-map sign-change-detector smoothed (cons-stream 0 smoothed))))