開発環境
- 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.1.を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
問題1.1.
入出力結果(Terminal, REPL(Read, Eval, Print, Loop))
$ gosh gosh> 10 ;; 10 10 gosh> (+ 5 3 4) ;; 12 12 gosh> (- 9 1) ;; 8 8 gosh> (/ 6 2) ;; 3 3 gosh> (+ (* 2 4) (- 4 6)) ;; 6 6 gosh> (define a 3) ;; a (3) a gosh> (define b (+ a 1)) ;; b (4) b gosh> (+ a b (* a b)) ;; 19 19 gosh> (= a b) ;; #f #f gosh> (if (and (> b a) (< b (* a b))) b a) ;; 4 4 gosh> (cond ((= a 4) 6) ((= b 4) (+ 6 7 a)) (else 25)) ;; 16 16 gosh> (+ 2 (if (> b a) b a)) ;; 6 6 gosh> (* (cond ((> a b) a) ((< a b) b) (else -1)) (+ a 1)) ;; 16 16 gosh> (exit) $
0 コメント:
コメントを投稿