Created
September 26, 2012 05:25
-
-
Save monmon/3786269 to your computer and use it in GitHub Desktop.
SICP q1.44
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
| ; たとえば | |
| ; f(0) = 1.0 | |
| ; f(1) = 3.0 | |
| ; f(2) = 9.0 | |
| ; f(3) = 27.0 | |
| ; f(4) = 81.0 | |
| ; のとき | |
| ; (smooth(f))(1) = 4.333 | |
| ; (smooth(f))(2) = 13.0 | |
| ; (smooth(f))(3) = 39.0 | |
| ; のようになればよい | |
| (define (smooth f) | |
| (lambda (x) | |
| (/ (+ (f (- x dx)) | |
| (f x) | |
| (f (+ x dx))) | |
| 3))) | |
| (define dx 1) | |
| (define (e i) (expt 3.0 i)) | |
| (print (e 0)) | |
| (print (e 1)) | |
| (print (e 2)) | |
| (print (e 3)) | |
| (print (e 4)) | |
| (newline) | |
| (print ((smooth e) 1)) | |
| (print ((smooth e) 2)) | |
| (print ((smooth e) 3)) | |
| (newline) | |
| ; smoothed fをrepeatedに与えればよい | |
| ; smmothed fは(smooth f)のことなので | |
| ; | |
| ;(load "./q1.43.scm") | |
| ;(define (n-fold-smooth f n) | |
| ; (repeated (smooth f) n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment