Exercise 3-77 Original
Exercise 3.77. The integral procedure used above was analogous to the "implicit" definition of the infinite stream of integers 3.5.2. Alternatively, we can give a definition of integral that's more like Integers-starting-from (also in section 3.5. 2):
(Define (integral integrand initial-value DT) (cons-stream initial-value (if (stream-null integrand) /c5> the-empty-stream (integral (stream-cd R integrand)(+ (* DT (stream-car integrand) ) (initial-value) dt ))))
When used on systems with loops, this procedure have the same problem as does our original version of integral. Modify the procedure so, it expects the integrand as a delayed argument and hence can be used in the solve procedure s Hown above.
Code
(Define (integral delayed-integrand initial-value DT) (Cons-streamInitial-value( Let (integrand (Force Delayed-integrand)) (if (stream-null integrand) The-empty-stream (integral ( stream-cdr integrand)) ( c13>+ (* DT (stream-car integrand)) initial-value) ( DT)) )))
"SICP Exercise" 142 Exercise 3.77