Replaced random-next with C version, which yields a much better random number generator.

Added shuffle-vector! for inplace random shuffling in a vector
This commit is contained in:
Sanel Zukan
2008-10-30 15:24:19 +00:00
parent a21f17fc1f
commit e19d0e46d5
5 changed files with 40 additions and 18 deletions

View File

@@ -541,17 +541,6 @@
(set-output-port prev-outport)
res)))))
; Random number generator (maximum cycle)
(define *seed* 1)
(define (random-next)
(let* ((a 16807) (m 2147483647) (q (quotient m a)) (r (modulo m a)))
(set! *seed*
(- (* a (- *seed*
(* (quotient *seed* q) q)))
(* (quotient *seed* q) r)))
(if (< *seed* 0) (set! *seed* (+ *seed* m)))
*seed*))
;; SRFI-0
;; COND-EXPAND
;; Implemented as a macro