計算機プログラムの構造と解釈[第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))の3(標準部品化力、オブジェクトおよび状態)、3.5(ストリーム)、3.5.3(ストリームパラダイムの開発)、信号としてのストリーム、問題 3.73.を解いてみる。
その他参考書籍
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
- プログラミングGauche (Kahuaプロジェクト (著), 川合 史朗 (監修), オライリージャパン)
問題 3.73.
コード(BBEdit, Emacs)
sample71.scm
#!/usr/bin/env gosh
;; -*- coding: utf-8 -*-
(load "./stream.scm")
(define (integral integrand initial-value dt)
(define int
(cons-stream initial-value
(add-streams (scale-stream integrand dt)
int)))
int)
(define (RC r c dt)
(define (inner i v)
(add-streams (scale-stream i r)
(integral (scale-stream i (/ 1 c))
v
dt)))
inner)
(define RC1 (RC 5 1 0.5))
(define (enumerate-interval low high)
(if (> low high)
'()
(cons low
(enumerate-interval (+ low 1)
high))))
(for-each (lambda (n)
(print (stream-ref (RC1 ones 0) n)))
(enumerate-interval 0 10))
入出力結果(Terminal(gosh), REPL(Read, Eval, Print, Loop))
$ ./sample73.scm 5 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 $
0 コメント:
コメントを投稿