From: Ramakrishnan Muthukrishnan Date: Sat, 6 Aug 2011 19:21:16 +0000 (+0530) Subject: added integral to streams library X-Git-Url: https://git.rkrishnan.org/a?a=commitdiff_plain;h=7bae9f6c273d2ecad8bee324d57802f3ecad6fe3;p=sicp.git added integral to streams library --- diff --git a/src/sicp/streams.rkt b/src/sicp/streams.rkt index b68afe1..e4252cd 100644 --- a/src/sicp/streams.rkt +++ b/src/sicp/streams.rkt @@ -120,4 +120,9 @@ (stream-cdr t)) (pairs (stream-cdr s) (stream-cdr t))))) - +(define (integral integrand initial-value dt) + (define int + (cons-stream initial-value + (add-streams (scale-stream integrand dt) + int))) + int)