![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SICP
文章平均质量分 74
SavageGarden_Love
这个作者很懒,什么都没留下…
展开
-
SICP学习笔记 1.1.6 条件表达式和谓词
练习1.1 1012836ab19#f416616 练习1.2 (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) 练习1.3 (define (min a b c) (if (< a...原创 2012-04-24 17:18:01 · 146 阅读 · 0 评论 -
SICP学习笔记 2.1.1 实例: 有理数的算术运算
练习 2.1(define (make-rat n d) (let ((g (gcd n d))) (if (and (< d 0) (> g 0)) (cons (/ (- n) g) (/ (- d) g)) (cons (/ n g) (/ d g))))) 1 ]=> (print-rat (make-rat 6 -7)...2012-08-18 21:44:02 · 129 阅读 · 0 评论 -
SICP学习笔记 2.1.2 抽象屏障
练习2.2(define (make-point x y) (cons x y))(define (x-point p) (car p))(define (y-point p) (cdr p)) (define (make-segment m n) (cons m n))(define (start-segment s) (car...原创 2012-08-18 22:05:35 · 196 阅读 · 0 评论 -
SICP学习笔记 2.1.3 数据意味着什么
练习2.4(define (new-cons x y) (lambda (m) (m x y)))(define (new-car z) (z (lambda (p q) p))) ;; 使用代换模型,(new-car (new-cons x y))的变换过程如下(new-car (new-cons x y))==> (new-car (...2012-08-26 11:07:41 · 131 阅读 · 0 评论 -
SICP学习笔记 2.1.4 扩展练习:区间算术
练习2.7;; 抽象对象"区间"有两个端点, 一个下界一个上界, 则直接有如下过程(define (lower-bound x) (car x))(define (upper-bound x) (cdr x)) 练习2.8(define (sub-interval x y) (make-interval (- (lower-bound ...2012-08-28 17:12:46 · 212 阅读 · 0 评论 -
SICP学习笔记 2.2.1 序列的表示
练习2.17;; 直接利用已经实现的list-ref和length过程即可(define (last-pair items) (if (null? items) (display "null") (list-ref items (- (length items) 1)))) 练习2.18;; 翻转即为将列表第二个...2012-08-31 17:31:46 · 149 阅读 · 0 评论 -
SICP学习笔记 2.2.4 实例:一个图形语言
练习2.44(define (up-split painter n) (if (= n 0) painter (let ((smaller (up-split painter (- n 1)))) (below painter (beside smaller smaller))))) 练习2.45...2012-12-11 21:49:45 · 265 阅读 · 0 评论 -
SICP学习笔记 2.3.2 实例:符号求导
练习2.56(define (deriv exp var) (cond ((number? exp) 0) ((variable? exp) (if (same-variable? exp var) 1 0)) ((sum? exp) (make-sum (deriv (addend exp) var) (deriv (augen...原创 2012-12-12 09:59:49 · 264 阅读 · 0 评论 -
SICP学习笔记 2.2.2 层次性结构
练习2.24;; 嵌套结构的list1 ]=> (list 1 (list 2 (list 3 4)));Value : (1 (2 (3 4))) */ \1 * / \ 2 * / \ 3 4 练习2.25;; (1 3 (5 7) 9)1 ]=> (def...2012-09-05 15:54:23 · 152 阅读 · 0 评论 -
SICP学习笔记 1.3.4 过程作为返回值
练习 1.40(define (cubic a b c) (lambda (x) (+ (cube x) (* a (square x)) (* b x) c)))1 ]=> (newtons-method (cubic 1.0 1.0 -3.0) 1.0);Value: 1. 练习 1.41(define (doub...2012-08-12 11:44:57 · 135 阅读 · 0 评论 -
SICP学习笔记 1.3.3 过程作为一般性的方法
练习 1.35φ^2 = φ+1 ==> φ = 1 + (1/φ) (define tolerance 0.00001)(define (fixed-point f first-guess) (define (close-enough? v1 v2) (< (abs (- v1 v2)) tolerance)) (define...2012-08-12 11:38:53 · 136 阅读 · 0 评论 -
SICP学习笔记 1.3.2 用lambda构造过程
练习 1.34 > (define (f g) (g 2)) > (f square) 4 > (f 2) procedure application: expected procedure, given: 2; arguments were: 2 2为数字,不是一个已定义的过程的名称...2012-07-13 08:50:53 · 201 阅读 · 0 评论 -
SICP学习笔记 1.2.1 线性的递归和迭代
练习1.9 对于过程 (define (+ a b) (if (= a 0) b (inc (+ (dec a) b)))) 计算(+ 4 5)时的替换过程为 -->(+ 4 5) -->(if (= 4 0) 5 (inc (+ (dec 4) 5))) -->(...2012-04-24 17:22:15 · 125 阅读 · 0 评论 -
SICP学习笔记 1.1.7 实例:使用牛顿法求平方根
练习1.6 应用序会对 (define (sqrt-iter guess x) (new-if (good-enough guess x) guess (sqrt-iter (improve guess x) x))) 的new-if中的else-clause(即(sqrt-iter (improve guess x) x))进行...2012-04-25 18:02:53 · 191 阅读 · 0 评论 -
SICP学习笔记 1.2.2 树形递归
练习1.11 递归过程 (define (func n) (if (< n 3) n (+ (* 1 (func (- n 1))) (* 2 (func (- n 2))) (* 3 (func (- n 3)))))) 迭代过程 (define (func n) (fun-...原创 2012-04-25 18:18:30 · 101 阅读 · 0 评论 -
SICP学习笔记 1.2.3 增长的阶
练习1.14(define (count-change amount) (cc amount 5))(define (cc amount kinds-of-coins) (cond ((= amount 0) 1) ((or (< amount 0) (= kinds-of-coins 0)) 0) (else (+ (cc amount (- kin...2012-05-09 21:06:18 · 326 阅读 · 1 评论 -
SICP学习笔记 1.2.4 求幂
练习1.16 根据提示, a*b^n保持不变、使用a来保存结果,观察如下变换过程 求b^100,(b n a) -->(b 100 a) -->(b^2 50 a) -->(b^4 25 a) 此时根据fast-expt的过程,应将25执行减1操作,如果保持a*b^n不变,则可有如下变换 -->(...2012-05-11 18:03:21 · 111 阅读 · 0 评论 -
SICP学习笔记 1.2.5 最大公约数
练习 1.20 (define (gcd a b) (if (= b 0) a (gcd b (remainder a b))))正则序 (gcd 206 40)--> (if (= 40 0) 206 (gcd 40 (r 206 40))) --> (gcd 40 ...2012-05-17 17:35:08 · 114 阅读 · 0 评论 -
SICP学习笔记 1.2.6 实例:素数检测
练习1.22;; runtime函数在stk、racket中都不支持,而GNU的Mit-Scheme十分难用,而且在Fedora16上编译安装后启动就报错,;; 后来总算是在selinux的提示下让它能够正常启动了;; grep scheme /var/log/audit/audit.log | audit2allow -M mypol;; semodule -i mypo...2012-06-04 11:08:47 · 162 阅读 · 0 评论 -
SICP学习笔记 1.3.1 过程作为参数
练习1.29 (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b)))) (define (integral f a b dx) (define (add-dx x) (+ x dx)) (* (s...2012-07-13 08:44:26 · 162 阅读 · 0 评论 -
SICP学习笔记 2.2.3 序列作为一种约定的接口
练习2.33;; map过程即为使用过程p作用x, 然后再合并作用y后的结果(define (map p sequence) (accumulate (lambda (x y) (cons (p x) y)) '() sequence));; append过程为合并两个列表, 则初始值为空表, 要传入的列表为枚举两个参数列表的元素组成的列表(define ...2012-09-14 17:48:41 · 201 阅读 · 0 评论