From 50ca3c0e96b8b27bd1a6960bbd4d67ff56b08318 Mon Sep 17 00:00:00 2001 From: DL-85 Date: Tue, 30 Apr 2019 14:03:52 +0800 Subject: [PATCH 1/2] Update 6-rand.scm --- chp3/code/6-rand.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chp3/code/6-rand.scm b/chp3/code/6-rand.scm index be6c9a1..4e1dfb7 100644 --- a/chp3/code/6-rand.scm +++ b/chp3/code/6-rand.scm @@ -6,7 +6,8 @@ (let ((state random-init)) (lambda (mode) (cond ((eq? mode 'generate) ; 产生随机数 - (random state)) + (begin (set! state (rand-update state)) + state)) ((eq? mode 'reset) ; 返回一个过程 (lambda (new-value) ; 这个过程将 state 修改为新值 new-value (set! state new-value) From d193edcb680e282a2c76ee81f045e8bca6486384 Mon Sep 17 00:00:00 2001 From: DL-85 Date: Tue, 30 Apr 2019 14:07:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=83=E4=B9=A03.6?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用书中的rand-update来完成新的rand过程,由于没有rand-update的定义,所以无法运行 --- chp3/6.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/chp3/6.rst b/chp3/6.rst index baa7af0..7e94908 100644 --- a/chp3/6.rst +++ b/chp3/6.rst @@ -1,8 +1,6 @@ 练习 3.6 ========== -.. warning:: 本解法有错误,正等待修复中,具体请参考: http://sicp.readthedocs.org/en/latest/chp3/6.html#comment-770974238 - 这题使用了 3.1.1 和 3.1.2 小节的状态、消息传递和随机数等知识: .. literalinclude:: code/6-rand.scm