開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- Gauche (処理系)
計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の1(手続きによる抽象の構築)、1.1(プログラミングの要素)、1.1.6(条件式と述語)、問題 1.3.を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
問題1.3.
入出力結果(Terminal, REPL(Read, Eval, Print, Loop))
$ gosh gosh> (define (square x) (* x x)) square gosh> (define (>= x y) (or (> x y) (= x y))) >= gosh> (define (proc a b c) (cond ((and (>= a c) (>= b c)) (+ (square a) (square b))) ((and (>= a b) (>= c b)) (+ (square a) (square c))) (else (+ (square b) (square c))))) proc gosh> (proc 2 3 4) 25 gosh> (proc 3 4 2) 25 gosh> (proc 4 2 3) 25 gosh> (proc 2 2 3) 13 gosh> (proc 3 2 2) 13 gosh> (proc 2 3 2) 13 gosh> (proc 2 2 2) 8 gosh> (exit) $
0 コメント:
コメントを投稿