sicp-ex-3.61



<< Previous exercise (3.60) | Index | Next exercise (3.62) >>


meteorgan



(define (reciprocal-series s)
  (cons-stream 1 (scale-stream (mul-series (stream-cdr s) (reciprocal-series s)) -1)))

leafac

I'm not sure the above solution works, because calling (reciprocal-series s) on the body creates a new stream, which results are not memoized.

Here's my version:

 (define (invert-unit-series series) 
   (define inverted-unit-series 
     (cons-stream 1 (scale-stream (mul-streams (stream-cdr series) 
                                               inverted-unit-series) 
                                  -1))) 
   inverted-unit-series) 
  

Why is it mul-streams, not mul-series?



xdavidliu

The point that leafac makes is exactly the topic of exercise 3.63; the very next exercise.