diff options
author | Jay Belanger <jay.p.belanger@gmail.com> | 2004-12-17 05:26:18 +0000 |
---|---|---|
committer | Jay Belanger <jay.p.belanger@gmail.com> | 2004-12-17 05:26:18 +0000 |
commit | a59a16878f6b78c4966d621cd792a16a0dbfe758 (patch) | |
tree | 9260e5ff0c49934d96fdb0d82af2580338f0017b /lisp/calc/calc-comb.el | |
parent | d1178128f874238abdff1fc4e4942f9d2faf357f (diff) | |
download | emacs-a59a16878f6b78c4966d621cd792a16a0dbfe758.tar.gz |
(math-random-last): Declare it.
(math-random-digit): Undo last change. Don't make math-random-last local.
(var-RandSeed): Don't initially bind it.
(math-init-random-base, math-random-digit): Check to see if
var-RandSeed is bound.
Diffstat (limited to 'lisp/calc/calc-comb.el')
-rw-r--r-- | lisp/calc/calc-comb.el | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el index 262db6c9bda..adb8fcecce6 100644 --- a/lisp/calc/calc-comb.el +++ b/lisp/calc/calc-comb.el @@ -540,12 +540,12 @@ ;;; Produce a random 10-bit integer, with (random) if no seed provided, ;;; or else with Numerical Recipes algorithm ran3 / Knuth 3.2.2-A. -(defvar var-RandSeed nil) +(defvar var-RandSeed) (defvar math-random-cache nil) (defvar math-gaussian-cache nil) (defun math-init-random-base () - (if var-RandSeed + (if (and (boundp 'var-RandSeed) var-RandSeed) (if (eq (car-safe var-RandSeed) 'vec) nil (if (Math-integerp var-RandSeed) @@ -599,9 +599,10 @@ ;;; Produce a random digit in the range 0..999. ;;; Avoid various pitfalls that may lurk in the built-in (random) function! ;;; Shuffling algorithm from Numerical Recipes, section 7.1. +(defvar math-random-last) (defun math-random-digit () - (let (i math-random-last) - (or (and var-RandSeed (eq var-RandSeed math-last-RandSeed)) + (let (i) + (or (and (boundp 'var-RandSeed) (eq var-RandSeed math-last-RandSeed)) (math-init-random-base)) (or math-random-cache (progn |