2014年1月18日土曜日

開発環境

計算機プログラムの構造と解釈(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.4.を解いてみる。

その他参考書籍

問題 1.4.

  1. (if (> b 0) + -)を評価
  2. (> b 0)を評価
  3. 演算子は+あるいは-になる
  4. (演算子 a b)を評価
  5. 値が返される

入出力結果(Terminal, REPL(Read, Eval, Print, Loop))

$ gosh
gosh> 
(define (a-plus-abs-b a b)
  ((if (> b 0) + -) a b))
a-plus-abs-b
gosh> (a-plus-abs-b 5 10)
15
gosh> (a-plus-abs-b 5 -10)
15
gosh> (exit)
$

0 コメント:

コメントを投稿