<< Previous exercise (3.60) | Index | Next exercise (3.62) >>
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?
(define (reciprocal-series s) (cons-stream 1 (scale-stream (mul-series (stream-cdr s) (reciprocal-series s)) -1)))
LisScheSic
This is wrong as leafac says. This problem also holds for the meteorgan's comment in http://community.schemewiki.org/?sicp-ex-3.55 (also see the special case in http://community.schemewiki.org/?sicp-ex-3.60).