Last active
August 29, 2015 14:25
-
-
Save cametan001/e641c963344c13b4fc2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Wikipediaの作例によるrand-update | |
(define (rand-update x) | |
(let ((a 3) (b 5) (m 13)) | |
(modulo (+ (* a x) b) m))) | |
;;; 乱数の初期値も Wikipedia に倣って8とする | |
(define random-init 8) | |
;;; SICP の rand | |
(define rand | |
(let ((x random-init)) | |
(lambda () | |
(set! x (rand-update x)) | |
x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment