計算機プログラムの構造と解釈[第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.1(データ抽象入門)、2.1.4(拡張問題: 区間算術演算)、問題 2.7.を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
- Scheme手習い
問題 2.7.
コード(BBEdit, Emacs)
(define make-interval
(lambda (a b) (cons a b)))
(define lower-bound
(lambda (interval) (car interval)))
(define upper-bound
(lambda (interval) (cdr interval)))
(define interval (make-interval 1 2))
(lower-bound interval)
(upper-bound interval)
入出力結果(Terminal(kscheme), REPL(Read, Eval, Print, Loop))
$ kscheme < sample7.scm In : Out: make-interval ;(total-pushes = 3 maximum-depth = 3) In : Out: lower-bound ;(total-pushes = 3 maximum-depth = 3) In : Out: upper-bound ;(total-pushes = 3 maximum-depth = 3) In : Out: interval ;(total-pushes = 17 maximum-depth = 7) In : Out: 1 ;(total-pushes = 8 maximum-depth = 3) In : Out: 2 ;(total-pushes = 8 maximum-depth = 3) In : $
0 コメント:
コメントを投稿