Created
March 15, 2013 01:53
-
-
Save yao2030/5166930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(load "stream-map.ss") | |
(load "ex59") | |
(define (scale-stream s f) | |
(stream-map (lambda (x) (* x f)) s)) | |
(define (mul-series s1 s2) | |
(cons-stream (* (stream-car s1) | |
(stream-car s2)) | |
(add-streams | |
(scale-stream (stream-cdr s2) (stream-car s1)) | |
(mul-series (stream-cdr s1) s2)))) | |
(define x cosine-series) | |
(define y sine-series) | |
(define z (add-streams (mul-series x x) (mul-series y y))) | |
(define (print-stream s) | |
(if (empty-stream? s) | |
'done | |
(begin (display (stream-car s)) | |
(display " ") | |
(print-stream (stream-cdr s))))) | |
;; Yangyang Qq: 451107669 | |
(define (invert-unit-series s) | |
(cons-stream 1 | |
(scale-stream | |
(mul-series (stream-cdr s) | |
(invert-unit-series s)) | |
-1))) | |
(define (div-series s1 s2) | |
(if (= (stream-car s2) 0) | |
(error "The denominator has a zero constant term") | |
(mul-series s1 (invert-unit-series s2)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment