sicp-ex-3.55



<< Previous exercise (3.54) | Index | Next exercise (3.56) >>


meteorgan

 (define (partial-sums s) 
         (cons-stream (stream-car s) (add-streams (stream-cdr s) (partial-sums s)))) 

huntzhan

  
 (define (partial-sums s) 
   (add-streams s (cons-stream 0 (partial-sums s)))) 
  

Mathieu Borderé

@huntzhan: nice, very elegant


lertecc

Must have self-reference to avoid recalculation:

  
 (define (partial-sums s) 
   (define ps (add-streams s (cons-stream 0 ps))) 
   ps)