程序的构造与解释
iteye_5681
这个作者很懒,什么都没留下…
展开
-
sicp第一章的练习题1.11 体会递归与迭代
sicp第一章的练习题1.11 体会递归与迭代 将表达式f(x) 当x>=3时 f(x) = f(x-1) + 2f(x-2) + 3f(x-3), 当x<3,f(x)=x 用递归和迭代表示 递归式 (define (compute n) (cond ((< n 0) 0) ((< n 3) n) (else (+ (com...2009-06-18 10:28:17 · 131 阅读 · 0 评论 -
SICP Exercise 1.22 遇到的问题
进行SICP Exercise 1.22 时遇到无法加载runtime过程的问题。 我的开发环境是DrScheme 4.2. 于是将原文的例子做了修改。修改例程和结果例程如下: 修改例程 (define (smallest-divisor n) (find-divisor n 2) ) (define (find-divisor n test-divisor) (c...2009-06-22 22:41:39 · 169 阅读 · 0 评论 -
SICP Exercise 1.31
(define (sum term a next b) (if (> a b) 1 (* (term a) (sum term (next a) next b)) )) (define (sum2 a b c from to) (if (= from to) c (sum2 (next...2009-06-25 23:21:59 · 132 阅读 · 0 评论 -
SICP Exercise 1.32-1.33
(define (accumulate combiner null-value term a next b) (if (> a b) null-value (combiner (term a ) (accumulate combiner null-value term (next a) next b) ) )...2009-06-30 21:57:20 · 115 阅读 · 0 评论 -
SICP Exercise 2.1-5
2.1 (define (make-rat-better n d) (if (< n 0) ( if(< d 0) (cons (- 0 n) (- 0 d)) (cons n d) ) (if (< d 0) (cons (- 0 n) (- 0 d)) ...2009-07-20 22:57:25 · 123 阅读 · 0 评论 -
SICP Exercise 2.17-
2.18 (define (reverse items) (if (null? (cdr items)) items (append (reverse (cdr items)) (list(car items))) ) ) (reverse (list 1 2 3 4)) 2.17 (define (list-pair it...2009-08-24 23:25:28 · 106 阅读 · 0 评论 -
SICP Exercise 2.19-
2.22 (define (for-each2 proc items) (proc (car items)) (if (null? (cdr items)) (newline) (for-each2 proc (cdr items)) ) ) 2.21 (define (square-list3 items) ...2009-08-25 18:26:07 · 132 阅读 · 0 评论 -
SICP Exercise 2.20+
(define x (list (list 1 2) (list 3 4))) x (car (cdr x)) (car x) (define (deep-reverse items) (display items) (newline) (cond ((null? items) ()) (( not (pair? items)) ite...2009-08-26 23:45:18 · 211 阅读 · 0 评论