計算機プログラムの構造と解釈[第2版]
(翔泳社)
ハロルド エイブルソン (著) ジュリー サスマン (著)
ジェラルド・ジェイ サスマン (著)
Harold Abelson (原著) Julie Sussman (原著)
Gerald Jay Sussman (原著) 和田 英一 (翻訳)
開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- kscheme, Gauche (処理系)
計算機プログラムの構造と解釈[第2版](ハロルド エイブルソン (著)、ジュリー サスマン (著)、ジェラルド・ジェイ サスマン (著)、Harold Abelson (原著)、Julie Sussman (原著)、Gerald Jay Sussman (原著)、和田 英一 (翻訳)、翔泳社、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の2(データによる抽象の構築)、2.2(階層データ構造と閉包性)、2.2.1(並びの表現)、リストの写像、問題2.21.を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
- Scheme手習い
問題2.21.
コード(BBEdit, Emacs)
(define square (lambda (x) (* x x)))
(define square-list1
(lambda (items)
(if (null? items)
'()
(cons (square (car items))
(square-list1 (cdr items))))))
(define square-list2
(lambda (items)
(map square (list 1 2 3 4))))
(square-list1 (list 1 2 3 4))
(square-list2 (list 1 2 3 4))
入出力結果(Terminal(kscheme), REPL(Read, Eval, Print, Loop))
$ gosh -i < sample21.scm gosh> square gosh> square-list1 gosh> square-list2 gosh> (1 4 9 16) gosh> (1 4 9 16) gosh> $
0 コメント:
コメントを投稿