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(f(x)) | |
| ; はq1.42のcomposeを使って | |
| ; ((compose f f) x) | |
| ; とかける | |
| ; | |
| ; ここでf(f(x))をg(x)とする | |
| ; | |
| ; f(f(f(x))) | |
| ; は |
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 |
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
| ; p.41のcube-rootを参考にコピペ | |
| (define (fixed-point f first-guess) | |
| (define tolerance 0.00001) | |
| (define (close-enough? v1 v2) | |
| (< (abs (- v1 v2)) tolerance)) | |
| (define (try guess) | |
| (let ((next (f guess))) | |
| (if (close-enough? guess next) | |
| next |
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
| ; p.13 1.1.7 sqrt | |
| (define (sqrt x) | |
| (sqrt-iter 1.0 x)) | |
| (define (sqrt-iter guess x) | |
| (if (good-enough? guess x) | |
| guess | |
| (sqrt-iter (improve guess x) | |
| x))) |
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
| (define nil '()) | |
| (define (accumulate op initial sequence) | |
| (if (null? sequence) | |
| initial | |
| (op (car sequence) | |
| (accumulate op initial (cdr sequence))))) | |
| ; 2.2.2 | |
| (define (count-leaves x) |
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
| (define nil '()) | |
| (define (accumulate op initial sequence) | |
| (if (null? sequence) | |
| initial | |
| (op (car sequence) | |
| (accumulate op initial (cdr sequence))))) | |
| (define (accumulate-n op init seqs) | |
| (if (null? (car seqs)) |
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
| (define nil '()) | |
| (define (accumulate op initial sequence) | |
| (if (null? sequence) | |
| initial | |
| (op (car sequence) | |
| (accumulate op initial (cdr sequence))))) | |
| (define (accumulate-n op init seqs) | |
| (if (null? (car seqs)) |
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
| (define nil '()) | |
| (define (accumulate op initial sequence) | |
| (if (null? sequence) | |
| initial | |
| (op (car sequence) | |
| (accumulate op initial (cdr sequence))))) | |
| (define fold-right accumulate) | |
| (define (fold-left op initial sequence) |
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
| (define nil '()) | |
| (define (accumulate op initial sequence) | |
| (if (null? sequence) | |
| initial | |
| (op (car sequence) | |
| (accumulate op initial (cdr sequence))))) | |
| (define fold-right accumulate) | |
| (define (fold-left op initial sequence) |
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
| ; まずp.71-72で以下のことまでは学習済み | |
| (define nil '()) | |
| (define (square x) (* x x)) | |
| (define (divides? a b) | |
| (= (remainder b a) 0)) | |
| (define (smallest-divisor n) | |
| (find-divisor n 2)) | |
| (define (find-divisor n test-divisor) | |
| (cond ((> (square test-divisor) n) n) |