<< Previous exercise (3.79) | Index | Next exercise (3.81) >>


 (define (RLC R L C dt) 
         (define (rcl vc0 il0) 
                 (define vc (integral (delay dvc) vc0  dt)) 
                 (define il (integral (delay dil) il0 dt)) 
                 (define dvc (scale-stream il (- (/ 1 C)))) 
                 (define dil (add-streams (scale-stream vc (/ 1 L)) 
                                                                 (scale-stream il (- (/ R L))))) 
                 (define (merge-stream s1 s2) 
                         (cons-stream (cons (stream-car s1) (stream-car s2)) 
                                                  (merge-stream (stream-cdr s1) (stream-cdr s2)))) 
                 (merge-stream vc il)) 

why not simply (cons vc il) at the end of the procedure instead of merging? the exercise says "a pair of the streams".

meteorgan has redefined the merging method. You idiot!

it's not necessary to insult people


 We could first compute the integral then scale the stream 
 (define (RLC R L C dt)  
   (define (proc vc0 il0) 
     (define vc (scale-stream (integral (delay il) (* (- C) vc0) dt) (/ -1 C))) 
     (define il (integral (delay dil) il0 dt)) 
     (define dil (add-streams (scale-stream il (/ (- R) L))  
                              (scale-stream vc (/ 1 L)))) 
     (stream-map cons vc il))