SICP 4.21

（本题的注释中拓展了一个叫Y运算的东西） 总体思想是：lambda是匿名函数，可以通过它自己的参数来绑定自己。 (define (fib n) ((lambda (f) (f f n)) (lambda (f k) (con...

2017/12/24 15:48
14
SICP 4.16

2017/12/22 18:20
10
SICP 4.9

2017/12/17 21:12
4
SICP 4.7

2017/12/17 20:24
3
SICP 3.66

2017/12/10 15:15
4
SICP 3.28 3.29 3.30

3.28 (define (or-gate a b output) (define (or-action) (let ((new-value (logic-or (get-signal a) (get-signal b)))) (after-delay or-gate-delay (lambda () (set-signal! ...

2017/10/03 17:01
5
SICP 3.22 3.23

3.23 思路：((a) (b) (c))这个列表本身做正序，(c)的cdr做prev指针 (define (make-deque) (let ((front-ptr '())   (rear-ptr '())) (define (empty?) (null? front-ptr)) (define ...

2017/09/12 23:44
11
SICP 3.17 3.18

3.17 只算序对数，不同的需要map辅助数据结构 (define (count-pairs x) (if (not (pair? x)) 0 (if (pair? (car x)) (+ 1 (count-pairs (car x)) (count-pairs (cdr...

2017/08/12 18:07
14
SICP 3.5 3.6

3.5 (define (random-in-range low high) (let ((range (- high low))) (+ low (random range)))) (define (make-circle-predicate r x y) (define (square z) (* z z)) (lam...

2017/07/27 19:56
3
SICP 2.82

(define (apply-generic op . args) (define (do-apply-generic type-args) (if (null? type-args) (error "error") (let ((type (type-tag (car type-args)))) ...

2017/07/09 20:48
19
SICP 2.76

2017/07/09 16:32
7
SICP 2.68 2.69 2.71 2.82

2.68 (define (encode-symbol x tree) (define (lookup x symbols) (if (null? symbols) #f (if (eq? x (car symbols)) #t (lookup x (cdr s...

2017/06/26 12:11
11
sicp 2.64

2017/06/10 00:40
14
SICP 2.61 2.62

2.61 (define (adjoin-set x set) (if (null? set) (list x) (let ((a (car set))) (cond ((eq? x a) set) ((< x a) (cons x set)) ((> ...

2017/06/05 20:00
5
SICP 2.56 2.57 2.58

2.56 (define (exponentiation? x) (and (pair? x) (eq? (car x) '**))) (define (base x) (cadr x)) (define (exponent x) (caddr x)) (define (make-exponentiation a b) (cond...

2017/06/05 11:27
16
SICP 2.40 2.41 2.42 2.43

2.40 (define (unique-pairs n) (flatmap (lambda (i) (map (lambda (j) (list i j)) (enumerate-interval 1 (- i 1)))) (enumerate-interval ...

2016/08/17 23:08
25
SICP 2.36 2.37 2.38 2.39

2.36 (map car seqs) (map cdr seqs) 2.37 (lambda (x) (dot-product x v)) cons '() (lambda (x) (map (lambda (y) (dot-product x y)) cols)) 2.38 3/2 1/6 (1 (2 (3 '()))) ((('() 1) 2)...

2016/08/14 21:52
10
SICP 2.33 2.34 2.35

2.33 (cons (p x) y) seq2 seq1 (lambda (x y) (+ 1 y)) 2.34 (+ this-coeff (* higher-terms)) 2.35 (define (my-count-leaves t) (accumulate + 0 (map (lambda (x) ...

2016/08/13 21:52
8
SICP 2.30 2.31 2.32

2.30 (define (square-tree tree) (cond ((null? tree) '()) ((pair? tree) (cons (square-tree (car tree)) (square-tree (cdr tree)))) ...

2016/08/07 14:54
32
SICP 2.27 2.28 2.29

2.27 (define (deep-reverse lst) (define (x-reverse l r) (cond ((null? l) r) ((pair? (car l)) (x-reverse (cdr l) (cons (x-reverse (car l) '()) r))) ...

2016/08/06 15:28
4