• Read older messages (September 29, 2008)
  • 9:34pm (September 29, 2008) 26x26yaotti
  • gaucheの場合,streamを返す手続きにはstream-delay使ったほうがいいみたいです.
  • 9:35pm (September 29, 2008) 26x26iwk
  • そういうことですか。
  • 実は、いまさらなんですが、ストリーム関連で謎の結構エラーが出ることが多かったのです。
  • 日本語が変。
  • 謎の結構×
    結構謎の○
    謎の結構×
    結構謎の○
  • 9:37pm (September 29, 2008) 26x26yaotti
  • gaucheとsicpでのschemeとは所々違う所があるので,reference読みながら進めていくのがいいですね.
  • 26x26iwk
  • ですね。
  • 今週はついに3章の最後、Exercise3.82まで。
  • 読み始めてから、もう11ヶ月になりますよ。
  • <eval,apply,η,ε> ?
  • ηとεは具体的にはなんなのだ?
  • 間違い。無視で。
  • 3:00pm (September 30, 2008) 26x26mehdi
  • hi yaotti
  • hi yaotti
  • hiiiiiiiiiiiiiiiiiiii
  • 9:54pm (September 30, 2008) 26x26iwk
  • mehdiさん、こんにちは。でも、大人気ないことは、しないでいただけると嬉しいです。
  • 11:21pm (October 01, 2008) 26x26iwk
  • Exercise3.80
  • A series RLC circuit consists of a resistor, a capacitor, and an inductor connected in series, as shown in figure 3.36.
  • 直列のRLC回路は、図3.36のように、抵抗と、コンデンサーと、回路に繋がれたインダクタンスから構成される。
  • If R, L, and C are the resistance, inductance, and capacitance, then the relations between voltage(v) and current(i) for the three components are described by the equations
  • ...
  • and the circuit connections dictate the relations ....
  • もしR,L,Cがそれぞれ、抵抗、インダクタンス、電気容量であるとき、3つの部品に係る電圧(v)と電流(i)は、以下の等式によって表現される
  • ...
  • そして、回路の接続により以下の関係が成り立つ。
  • ...
  • Combining these equations shows that the statte of the circuit (summarized by v_C, the voltage across the capacitor, and i_L, the current in the inductor) is described by the pair of differential equations
  • これら等式の組み合わせは、回路の状態(...略...)は以下の微分方程式のペアによって記述されることを示す。
  • ...
  • The signal-flow diagram representing this system of differential equations is shown in figure 3.37.
  • 図3.37は、この微分方程式を表現している信号フローのダイアグラムを表している。
  • Write a procedure RLC that takes as arguments the parameters R,L, and C of the circuit and the time increment dt.
  • RLCプロシージャを書け。RLCプロシージャは、引数として回路のR,LそしてCを取り、dtずつ時間発展してゆく。
  • In a manner similar to that of the RC procedure of exercise3.73, RLC should produce a procedure that takes the initial values of the state variables, v_C0 and i_L0, and produces a pair(using cons) of the streams of states v_C and i_L.
  • aruimi
  • 間違い。
  • なお、ある程度、練習問題3.73におけるRCプロシージャのつくりと類似させよ、RLC は,
  • 状態変数の初期値v_C0、i_L0を(引数に)取り、そして、状態v_Cとi_Lストリームの(consを用いた)ペアを生成する。
  • Using RLC, generic the pair of streams that models the behavior of a series RLC circuit with R=1 ohm, C=0.2 farad, L=1 henry, dt=0.1 second, and initial values i_L0=0 amps and v_C0=10 volts.
  • RLCを用いて直列RLC回路の振る舞いを模るストリームのペアを生成せよ。
  • なお、R=1Ω、C=0.2F、L=1H,dt=0.1sとし、初期値i_L0は0A、v_C0=10Vとせよ。
  • -----
  • 電気回路なんて、もうほとんど忘れてしまいましたよ。
  • 私は物理学科だったもので。一応回路はやった?のです。
  • まぁどうでもいいですね。
  • 9:52pm (October 02, 2008) 26x26iwk
  • (define (RLC R L C dt)
    (lambda (v_C0 i_L0)
    (define v_C (integral (delay (scale-stream i_L (/ 1 (- C)))) v_C0 dt))
    (define i_L (integral (delay (add-streams (scale-stream v_C (/ 1 L))
    (scale-stream i_L (/ (- R) L))))
    i_L0 dt))
    (cons v_C i_L)))
    (define (RLC R L C dt)
      (lambda (v_C0 i_L0)
        (define v_C (integral (delay (scale-stream i_L (/ 1 (- C)))) v_C0 dt))
        (define i_L (integral (delay (add-streams (scale-stream v_C (/ 1 L))
    					      (scale-stream i_L (/ (- R) L))))
    			  i_L0 dt))
        (cons v_C i_L)))
  • 正解をみたら、一応あっていた。
  • 11:36pm (October 04, 2008) 26x26iwk
  • http://en.wikipedia.org/wiki/Scheme_(programming_language)
  • ふと、これ訳したほうがいいなと思いました。
  • 探せば普通に見つかるものなのに、改めて指摘されないとわからないというのは、少しだけ悔しいですね・・・。
  • プログラミングに興味を持たせるには、案外、その言語の進歩歴史を教えてしまうと
  • いいのかもしれないですね。
  • 進歩歴史×
    進歩の歴史○
    進歩歴史×
    進歩の歴史○
  • 6:30pm (October 05, 2008) 26x26yaotti
  • 結構間が空いてしまった.4.3.3 amb evaluatorの実装へ.
  • 9:55pm (October 06, 2008) 26x26iwk
  • 昨日はまた居眠りしてしまいました.orz
  • Exercise3.81
  • Exercise 3.6 discussed generalizing the random-number generator to allow one to reset the random-number sequence so as to produce repeatable sequences of "random" numbers.
  • 練習問題3.6において、繰り返し可能な「ランダムな」数の列を生成するために、乱数の列をリセットすることができる乱数生成機を作ることを議論した。
  • イマイチ。
  • Produce a stream formulation of this same generator that operates on an input stream of requests to generate a new random number or to reset the sequence to a specified value and that produces the desired stream of random numbers.
  • 同様の生成機のストリーム版を作れ。
  • 生成機(もとい、ジェネレータ)は新たな乱数を生成することを求める入力ストリームに作用する、
  • もしくは、明示された値に列をリセットすること(を求める入力ストリームに作用する)、
  • そして、望まれた乱数のストリームを作り出す。
  • ダメすぎる。orz
  • Don't use assignment in your solution.
  • なお、あなたの答えにおいては、破壊的代入を行ってはいけない。
  • letは式への項の代入、すなわち、substitutionの方の代入なのでOKですね。
  • あくまでassignmentするなと言っていますし。
  • (define (make-rand-stream)
    (let ((mt (make <mersenne-twister> :seed (sys-time)))
    (range 10000))
    (let ((random-init (mt-random-integer mt range)))
    (define (rand-update y)
    (mt-random-set-seed! mt y)
    (mt-random-integer mt range))
    (define (generate new-value)
    (define rand-numbers
    (cons-stream new-value
    (stream-map rand-update rand-numbers)))
    rand-numbers)
    (define (dispatch m)
    (cond ((eq? m 'generate) (generate random-init))
    ((eq? m 'reset) (lambda (new-value) (generate new-value)))
    (else
    (error "Unknown method -- MODIFIED-RAND" m))))
    dispatch)))
    (define rand-generator (make-rand-stream))
    (define random-numbers (rand-generator 'generate))
    (define (make-rand-stream)
      (let ((mt (make <mersenne-twister> :seed (sys-time)))
    	(range 10000))
        (let ((random-init (mt-random-integer mt range)))
          (define (rand-update y)
    	(mt-random-set-seed! mt y)
    	(mt-random-integer mt range))
          (define (generate new-value)
    	(define rand-numbers
    	  (cons-stream new-value
    		       (stream-map rand-update rand-numbers)))
    	rand-numbers)
          (define (dispatch m)
    	(cond ((eq? m 'generate) (generate random-init))
    	      ((eq? m 'reset) (lambda (new-value) (generate new-value)))
    	      (else
    	       (error "Unknown method -- MODIFIED-RAND" m))))
          dispatch)))
    (define rand-generator (make-rand-stream))
    (define random-numbers (rand-generator 'generate))
  • こうかなぁ・・。どうも題意を満たしていない気がする。
  • 特にresetメソッド。
  • まぁ悩んでいても仕方ない。
  • Exercise 3.82
  • Redo exercise 3.5 on Monte Carlo integration in terms of streams.
  • ストリームに置き換えたモンテカルロ積分を用いて、練習問題3.5をやり直せ。
  • onの用法無視。
  • The stream version of estimate-integral will not have an argument telling how many trials to perform.
  • estimate-integralのストリーム版は、何度試みるのかについて知らせている引数を取らないであろう。
  • (つまり末尾のtrial引数を取らない。)
  • Instead, it will produce a stream of estimates based on successively more trials.
  • その代わり、連続的により多くの試みをベース(要素)に、見積もりのストリームを生成するであろう。
  • ムズイ。読み取れている気がしない。
  • うーん。難しい。
  • とりあえず、yaottiさんお待たせしました、今週はついに4章に入ります。
  • というわけで、Exercise4.3まで。
  • (define rand-nums
    (letrec ((mts (cons-stream mt mts)))
    (stream-map mt-random-real0 mts)))

    (define (pred x y)
    (<= (+ (square (- x 0)) (square (- y 0))) (square 1)))

    (define estimate-integral-stream-ver
    (let ((the-entire-rectangle (* 2 2))
    (experiments (map-successive-pairs pred rand-nums)))
    (scale-stream (monte-carlo experiments 0 0) the-entire-rectangle)))
    (define rand-nums
      (letrec ((mts (cons-stream mt mts)))
        (stream-map mt-random-real0 mts)))
    
    (define (pred x y)
      (<= (+ (square (- x 0)) (square (- y 0))) (square 1)))
    
    (define estimate-integral-stream-ver
      (let ((the-entire-rectangle (* 2 2))
    	(experiments (map-successive-pairs pred rand-nums)))
        (scale-stream (monte-carlo experiments 0 0) the-entire-rectangle)))
  • こんな感じかな。
  • 今日はここまで。
  • 9:38pm (October 07, 2008) 26x26yaotti
  • お,4章に入りましたか.おめでとうございます.
  • 3:20pm (October 08, 2008) 26x26BF
  • http://www.konjedel.blogfa.com/ وبلاگمه
  • 9:16pm (October 08, 2008) 26x26iwk
  • 4章最初のページの要約。
  • 現実に存在する複雑な問題を表現するのに適した新しい言語を作りたい。
  • と、解釈しました。
  • なお、適当に述べているだけなので、適当に無視してください。
  • 2ページ目。
  • 新しい言語を作り出すような、メタ言語抽象は全ての工学的問題の描写で重要な役割を果たす。それはなぜかというと、プログラミングにおいては、新しい言語の構文を作ると同時にその意味も構成することになるからだ。
  • その意味も×
  • その構文の意味も○
  • プログラミング言語における式の意味を決定する評価機は、単なるプログラムである。
  • これがプログラミングにおける最も基本的なアイディアである。
  • つまり、プログラミング言語の式の意味合いと言うのは、現実を超越した何かが、理解不可能な手法で意味を定めてくるわけではなくて、自分自身で自分の意味を定めることができるんだ、ということなのだと思います。
  • 簡単にいうと、プログラムの意味と言うのは個人個人で勝手に作ってしまっても良い、みたいな意味なのかな。
  • 漠然と「意味」といっても困惑するだけですね。私がいう意味とは、例えば、チャーチ数のzero
  • (lambda (f) (lambda (x) x)))
  • exercise2.6参照
  • を、評価(eval)する、すなわち、
  • (eval (lambda (f) (lambda (x) x))) するとその結果としては0だ、ぐらいの意味です。
  • わかりづらい。
  • つまり、この場合だと(lambda (f) (lambda (x) x))には0という(我々が普段使ってよくわかる)ものに対応させるんだ、(そしてそれは我々が勝手に定めるんだ)ということです。
  • あんまり言うべきでは無いんでしょうけれど、evalは多分、函手と解釈すべきなんだと思います。
  • 函手と言うのは異なるカテゴリ同士のものを対応させる射と解釈しています。
  • うーん。これは滅入る。orz
  • ヤメヤメ。なんだかよくわかりませんが、消耗が激しい。
  • 10:45pm (October 08, 2008) 26x26xxx6
  • hi
  • 10:49pm (October 08, 2008) 26x26iwk
  • xxx6さんこんにちは。
  • 2:07am (October 09, 2008) 26x26iwk
  • http://www.littlewingpinball.net/mediawiki-ja/index.php/Ypsilon_Scheme_System#Linux
  • こういうのあったんですね。
  • 8:26pm (October 09, 2008) 26x26iwk
  • ypsilonはsrfiロードできるのかなぁ。
  • http://www.littlewingpinball.net/mediawiki-ja/index.php/Ypsilon_Scheme_System#bash
  • とあるのですが、rlwrapには-qオプションないですよね。
  • http://utopia.knoware.nl/~hlub/rlwrap/CHANGES.txt
  • 0.3で追加されたのですね。
  • schemeといえばgaucheで完全にデファクト・スタンダードだったので、ypsilonに乗り換えようと思うと少し勇気がいる。
  • でも、ちょっとR6RS試してみたいんですよね。
  • http://www.littlewingpinball.net/mediawiki-ja/index.php/Ypsilon_Scheme_System#.E3.81.9D.E3.81.AE.E4.BB.96.E3.81.AE.E4.BE.BF.E5.88.A9.E3.81.AA.E6.A9.9F.E8.83.BD
  • これも便利そうですし。
  • streamが使えるとわかって安心。
  • 10:03pm (October 10, 2008) 26x26iwk
  • The Core of the Evaluator
  • The evaluation process can be described as the interplay between two procedures: eval and apply.
  • 評価のプロセスはevalとapply2つのプロシージャの連動として記述される。
  • Eval
  • Eval takes as arguments an expression and an environment.
  • Evalは環境とプログラム式を引数として取る。
  • Eval is structured as a case analysis of the syntactic type of the expression to be evaluated.
  • Evalは評価されるプログラム式の構文型の構造解析するものとして、構築されている。
  • In order to keep the procedure general, we express the determination of the type of an expression abstractly, making no commitment to any particular representation for the various types of expressions.
  • プロシージャの一般性を保つ為に、抽象的にプログラム式における型を明示する、多様型に対しては特定の表現は定めないこととする。
  • Each type of expression has a predicate that tests for it and an abstract means for selecting its parts.
  • プログラム式の各々の型は、プログラム式について語る述語と、プログラム式の部分の選択について抽象的な意味を持つ。
  • ----
    私は、述語と集合の区別がついていないので、変な訳になっています。
    ----
    ----
    私は、述語と集合の区別がついていないので、変な訳になっています。
    ----
  • This abstract syntax makes it easy to see how we can change the syntax of the language by using the same evaluator, but with a different collection of syntax procedures.
  • この抽象的な構文は、同一の評価機で言語の構文をどれだけ変更することができるのか観察することを容易にする。しかし、構文プロシージャ(構文を構成するプロシージャ?)の異なる集まりを生み出してしまう。
  • うーん。意味がわかりません。
  • Primitive expressions
  • ・For self-evaluating expressions, such as numbers, eval returns the expression itself.
  • ・数字のような、自己評価を行うプログラム式について、evalはそのプログラム式自身を返す。
  • ×
  • ・自身が意味をもつ(例えば、数字)プログラム式について、evalはそのプログラム式自身を返す。
  • Eval must look up variables in the environment to find their values.