From: Ramakrishnan Muthukrishnan Date: Thu, 6 Jan 2011 15:38:25 +0000 (+0530) Subject: solution to 3.6 X-Git-Url: https://git.rkrishnan.org/pf/content/frontends/about.html?a=commitdiff_plain;h=3f742d7585961177b69965acfaff11f3ebc89a9e;p=sicp.git solution to 3.6 --- diff --git a/src/sicp/ex3_6.rkt b/src/sicp/ex3_6.rkt new file mode 100644 index 0000000..fcfa106 --- /dev/null +++ b/src/sicp/ex3_6.rkt @@ -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)) + +