]> git.rkrishnan.org Git - sicp.git/commitdiff
solution to 3.6
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 6 Jan 2011 15:38:25 +0000 (21:08 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 6 Jan 2011 15:38:25 +0000 (21:08 +0530)
src/sicp/ex3_6.rkt [new file with mode: 0644]

diff --git a/src/sicp/ex3_6.rkt b/src/sicp/ex3_6.rkt
new file mode 100644 (file)
index 0000000..fcfa106
--- /dev/null
@@ -0,0 +1,16 @@
+#lang racket
+
+(define rand
+  (let ((x random-init))
+    (define (dispatch type)
+      (cond
+        ((eq? type 'generate)
+         (begin
+           (set! x (rand-update x))
+           x))
+        ((eq? type 'reset)
+         (lambda (new-val)
+           (set! x new-val)))))
+    dispatch))
+
+