![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SICP
zhangle2006
这个作者很懒,什么都没留下…
展开
-
Ackermann函数
Ackermann函数的定义见图。 详细请参考[url]http://en.wikipedia.org/wiki/Ackermann_function[/url](A 1 n) = 2^n (A 2 n) = 2^(2^(2^(....^(2^2)))) (共n个2)用scheme语音定义为[code="java"](define (A x y) (cond ((= ...2008-10-09 10:35:52 · 253 阅读 · 0 评论 -
sicp 习题 2.21 ~ 2.25
2.21[code="java"](define nil '())(define (square x) (* x x))(define (square-list items) (if (null? items) nil (cons (square (car items)) (square-list (cdr items)))))...2008-11-04 11:53:44 · 181 阅读 · 0 评论 -
sicp 习题 2.17 ~ 2.20
2.17[code="java"](define (my-last-pair l) (if (null? (cdr l)) (car l) (last-pair (cdr l))))(my-last-pair (list 23 72 149 34))[/code]2.18[code="java"](define (my-reve...2008-11-04 11:51:10 · 257 阅读 · 0 评论 -
sicp 习题 2.12 ~ 2.13
2.12[code="java"](define (add-interval x y) (make-interval (+ (lower-bound x) (lower-bound y)) (+ (upper-bound x) (upper-bound y))))(define (sub-interval x y) (add-inte...2008-11-04 11:49:10 · 155 阅读 · 0 评论 -
sicp 习题 2.6 ~ 2.10
2.6[code="java"](define zero (lambda (f) (lambda (x) x)))(define (add-1 n) (lambda (f) (lambda (x) (f ((n f) x)))))((zero 4) 3)(add-1 5 1)[/code]2.7[code="java"](define (add-interva...2008-10-27 11:43:49 · 167 阅读 · 0 评论 -
sicp 习题 2.1 ~ 2.5
2.1[code="java"](define (make-rat n d) (let ((g (gcd n d))) (cond ((and (< n 0) (> d 0)) (cons (/ n g) (/ d g))) ((and (> n 0) (> d 0)) (cons (/ n g) (/ d g))) (else (c...2008-10-15 16:49:45 · 164 阅读 · 0 评论 -
sicp 习题 1.42 ~ 1.46
1.42[code="java"](define (my-compose f g) (lambda (x) (f (g x))))(define (inc x) (+ x 1))(define (square x) (* x x))((my-compose square inc) 6)[/code]1.43[code="java"...2008-10-15 16:47:54 · 144 阅读 · 0 评论 -
sicp 习题 1.38 ~ 1.41
1.38[code="java"](define (cont-frac n d i k) (if (= k 1) (/ (n 1) (d 1)) (/ (n i) (+ (d i) (cont-frac n d (+ i 1) (- k 1))))))(define (cont-frac-r n d k) (define (frac i) ...2008-10-15 16:45:47 · 150 阅读 · 0 评论 -
sicp 习题 1.34 ~ 1.37
1.34[code="java"](define (square n) (* n n))(define (f g) (g 2))(f square)(f (lambda (z) (* z (+ z 1))))(f f)[/code]1.35[code="java"](define tolerance 0.00001)(define...2008-10-15 16:43:55 · 188 阅读 · 0 评论 -
sicp 习题 1.29 ~ 1.33
1.29[code="java"](define (inc n) (+ n 1))(define (cube a) (* a a a))(define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b))))(define ...2008-10-15 16:41:45 · 216 阅读 · 0 评论 -
sicp 习题 1.21 ~ 1.22
1.21[code="java"](define (smallest-divisor n) (find-divisor n 2))(define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-diviso...2008-10-15 16:38:16 · 147 阅读 · 0 评论 -
sicp 习题 1.10 ~ 1.17
1.10[code="java"](define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) (else (A (- x 1) (A x (- y 1))))))(define (f n) (A 0 n))(defi...2008-10-15 16:35:17 · 222 阅读 · 0 评论 -
sicp 习题 2.26 ~ 2.30
2.26[code="java"](define x (list 1 2 3))(define y (list 4 5 6))(append x y)(cons x y)(list x y)(define z (list x y))(car z)(cdr z)[/code]2.27[code="java"](define nil '(...2008-11-04 12:00:52 · 164 阅读 · 0 评论