Fork me on GitHub

随笔分类 -  计算机程序的构造和解释

Structure and Interpretation of Computer Programs
SICP学习笔记 - 第二章 (2.3)
摘要:基本过程:1 (eq? <symbol1> <symbol2>) ;判断连个符号是否相同2 (cadr <list>) => (car (cdr <list>))3 (number? <num>)4 (symbol? <sym>)范例:霍夫曼编码树定长编码(fixed-length codes):采用同样数目的二进制位表示消息中的每个字符。变长编码(variable-length codes):采用不同数目的二进制位表示不同字符。前缀码(prefix code):每个字符的完整编码都不是另一字符的开始一段。霍夫曼编码 阅读全文
posted @ 2012-11-13 13:35 sungoshawk 阅读(232) 评论(0) 推荐(0)
SICP学习笔记 - 第二章 (2.2)(下)
摘要:设计原则:约定的界面(conventional interfaces)。范例:“流结构”化的 sum-odd-squares 和 even-fibs 1 (define (filter predicate sequence) 2 (cond ((null? sequence) '()) 3 ((predicate (car sequence)) 4 (cons (car sequence) 5 (filter predicate (cdr sequence)))) 6 (else (filter... 阅读全文
posted @ 2012-11-11 00:55 sungoshawk 阅读(404) 评论(0) 推荐(0)
SICP学习笔记 - 第二章 (2.2)(上)
摘要:闭包:通过闭包组合起数据对象得到的结果本身还可以通过同样的操作再进行组合。 (In general, an operation for combining data objects ststisfies the closure property if the results of combining things with that operation can themselves be combined using the same operation.)序列(sequence):如图所示,序列由一个序对(pair)的链表(list)表示。每个序对的 car 部分对应于这个链中的条目, c. 阅读全文
posted @ 2012-11-09 23:33 sungoshawk 阅读(296) 评论(0) 推荐(0)
SICP学习笔记 - 第二章 (2.1)
摘要:基本过程:1 (cons n d)2 (car x)3 (cdr x)部分习题:exercise 2.11 (define (make-rat n d)2 (let ((g (gcd n d)))3 (if (negative? (* n d))4 (cons (- (abs (/ n g))) (abs (/ d g)))5 (cons (abs (/ n g)) (abs (/ d g))))))exercise 2.2 1 (define (average x y) 2 (/ (+ x y) 2)) 3 (d... 阅读全文
posted @ 2012-11-03 23:09 sungoshawk 阅读(235) 评论(0) 推荐(0)
SICP学习笔记 - 第一章 (1.3)
摘要:特殊形式(special form):1 (lambda (<formal-parameters>) <body>)2 (let ((<var1> <exp1>)3 ...4 (<varn> <expn>))5 <body>)等价形式: 1 (define (plus4 x) (+ x 4)) 2 等价于 3 (define plus4 (lambda (x) (+ x 4))) 4 5 (let ((<var1> <exp1>) 6 ... 7 (<varn> <ex 阅读全文
posted @ 2012-11-02 00:23 sungoshawk 阅读(288) 评论(0) 推荐(0)
SICP学习笔记 - 第一章 (1.2)
摘要:递归计算过程(recursive process):这种类型的计算过程由一个推迟执行的运算链条刻画。迭代计算过程(iterative process):其状态可以用固定数目的状态变量描述。与此同时,又存在一套固定规则,描述了计算过程从一个状态到下一个状态转换时,变量的更新方式,还有一个结束检测,描述计算过程应该终止的条件。范例:换零钱 1 (define (count-change amount) 2 (cc amount 5)) 3 (define (cc amount kinds-of-coins) 4 (cond ((= amount 0) 1) 5 ... 阅读全文
posted @ 2012-10-31 14:13 sungoshawk 阅读(255) 评论(0) 推荐(0)
SICP学习笔记 - 第一章 (1.1)
摘要:语言的三个机制:基本表达式 (primitive expression)组合 (combination)抽象 (abstraction)组合式:由括号括起的一些表达式,形成的表。表中最左边的元素称为运算符(operator),其他元素称为运算对象(operand)。过程定义的一般形式:(define (<name> <formal parameters>) <body>)应用序(application order):求值参数而后应用正则序(normal order):完全展开而后归约特殊形式(special form):1 (define (<name 阅读全文
posted @ 2012-10-30 11:09 sungoshawk 阅读(287) 评论(0) 推荐(0)