計算機プログラムの構造と解釈[第2版]
(翔泳社)
ハロルド エイブルソン (著) ジュリー サスマン (著)
ジェラルド・ジェイ サスマン (著)
Harold Abelson (原著) Julie Sussman (原著)
Gerald Jay Sussman (原著) 和田 英一 (翻訳)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- Gauche (処理系)
計算機プログラムの構造と解釈[第2版](ハロルド エイブルソン (著)、ジュリー サスマン (著)、ジェラルド・ジェイ サスマン (著)、Harold Abelson (原著)、Julie Sussman (原著)、Gerald Jay Sussman (原著)、和田 英一 (翻訳)、翔泳社、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の4(超言語的抽象)、4.1(超循環評価器)、4.1.1(評価器の中核)、問題 4.1を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
問題 4.1
コード(BBEdit, Emacs)
sample81.scm
#!/usr/bin/env gosh
;; -*- coding: utf-8 -*-
;; 被演算子を左から右に評価
(define (list-of-values exps env)
(if (no-operands? exps)
'()
((lambda (x)
(cons x (list-of-values (rest-operands exps) env)))
(eval (first-operand exps) env))))
;; 被演算子を右から左に評価
(define (list-of-values-right-to-left exps env)
(if (no-operands? exps)
'()
((lambda (x)
(cons (eval (first-operand exps) env) x))
(eval (rest-operands exps) env))))
0 コメント:
コメントを投稿