開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- MIT/GNU Scheme (処理系)
計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の5(レジスタ計算機での計算)、5.5(翻訳系)、翻訳系の概観、5.5.7(翻訳したコードと評価器のインターフェース)、解釈と翻訳、問題 5.50.を解いてみる。
その他参考書籍
問題 5.50.
コード(BBEdit)
sample.scm
(load "./eceval.scm") (compile-and-go '(begin ;; 超循環評価器のコード ))
入出力結果(Terminal, REPL(Read, Eval, Print, Loop))
$ scheme MIT/GNU Scheme running under MacOSX Type `^C' (control-C) followed by `H' to obtain information about interrupts. Copyright (C) 2011 Massachusetts Institute of Technology This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Image saved on Saturday October 26, 2013 at 11:02:50 PM Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/C 4.118 Edwin 3.116 1 ]=> (load "./sample.scm") ;Loading "./sample.scm"... ; Loading "./eceval.scm"... done ; ... done (total-pushes = 1627 max-depth = 120) ;;; EC-Eval value: ok ;;; EC-Eval input: (driver-loop) ;;; M-Eval input: 10 ;;; M-Eval value: 10 ;;; M-Eval input: (+ 10 20) ;;; M-Eval value: 30 ;;; M-Eval input: (define (factorial n) (if (= n 1) 1 (* (factorial (- n 1)) n))) ;;; M-Eval value: ok ;;; M-Eval input: (factorial 10) ;;; M-Eval value: 3628800 ;;; M-Eval input: End of input stream reached. Moriturus te saluto. $
問題の記述にある通り、階乗計算(10!)で非常にゆっくり走った。
0 コメント:
コメントを投稿