23. (define (cons x y)
(define (dispatch m)
(cond ((= m 0) x)
((= m 1) y)
(else (error "Argument not 0 or 1 --
CONS" m))))
dispatch)
(cons x y)は手続きdispatchを返します。
この手続きdispatchは引数を1つとり、
0が渡されるとx, 1が渡されるとyを返します。
58. これから定義するもの
(dot-product v w) 総和 を返す(ベクトルの内積)
(matrix-*-vector m v) であるようなベクトルtを返す
(matrix-*-matrix m n) であるような行列pを返す
(transpose m) であるようなマトリックスnを返す
71. SICP
• Welcome to the SICP Web Site
– http://mitpress.mit.edu/sicp/
– 邦題: 「計算機プログラムの構造と解釈」
– 今回は第2章の”データによる抽象の構築”の部
分を俯瞰するような形でスライドを構成しま
した。とても良い話です。
72. • Why <cite>Structure and Interpretation of
Computer Programs</cite> matters
– http://www.eecs.berkeley.edu/~bh/sicp.html
– <blockquote>The invention of the MapReduce
software for data parallelism at Google, based
on functional programming ideas, has helped
eliminate that ivory-tower
reputation.</blockquote>
75. cons, car, cdrの名前の由来
• cons
– Construct
• car
– Contents of the Address part of the Register.
• cdr
– Contents of the Decrement part of the
Register
76. accumulate
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
77. accumulate-n
(define (accumulate-n op init seqs)
(if (null? (car seqs))
nil
(cons (accumulate op init (map car seqs))
(accumulate-n op init (map cdr seqs)))))