Skip to content

Instantly share code, notes, and snippets.

@cametan001
Last active August 29, 2015 14:25
Show Gist options
  • Save cametan001/e641c963344c13b4fc2d to your computer and use it in GitHub Desktop.
Save cametan001/e641c963344c13b4fc2d to your computer and use it in GitHub Desktop.
;;; 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