加载中
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

代码如下: (define (scan-out-defines exp) (define (iter exp defines nodefines) (if (null? exp) (list defines nodefines) (let ((x (car exp))) (if ...

2017/12/22 18:20
10
SICP 4.9

设计一个for循环: (for <init> <condition> <update> <body>) (for ((a 0) (b 1)) (and (< a 10) (< b 11)) ((set! a (+ a 1)) (set! b (+ b 1))) (print a) (print b)) ...

2017/12/17 21:12
4
SICP 4.7

题目的例子等价于: (let ((x 3)) (let ((y (+ x 2))) (let ((z (+ x y 5))) (* x z)))) 于是代码如下: (define (make-let bindings body) (cons 'let (cons bindings bod...

2017/12/17 20:24
3
SICP 3.66

本题的求(1,100)的问题给出了整个题目的思路,本题涉及解递推(归)方程 设f(n,i,j)为从第n行开始(i,j)的位置,n,i,j从0开始,则从(i,j)的当前行开始(i,j)所在的位置 f(i,i,j) = (j-i-1)*2+1...

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

新类型 新操作 dispatch 每个通用型操作都需要增加类型处理代码 每个类型都要加入新操作的代码,额外的dispatch代码 dd 只需在类型-操作表中新增 每个类型都要加入新操作的代码,且需更新操作...

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

本题考察理解递归代码的方法和表达能力。 a. 对有序列表作递归调用,划分为左右两部份,并以左右两部份分别生成左子树和右子树,最终生成平衡二叉树。对(1 3 5 7 9 11)的执行过程如下: part...

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

没有更多内容

加载失败,请刷新页面

返回顶部
顶部