1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +02:00

elisp rng

* module/language/elisp/boot.el (random): New function.
This commit is contained in:
BT Templeton 2012-03-07 20:09:21 -05:00
parent 43ff6804d6
commit 52d2472441

View file

@ -596,3 +596,18 @@
(defun prin1-to-string (object) (defun prin1-to-string (object)
(format* nil "~S" object)) (format* nil "~S" object))
;; Random number generation
(defvar %random-state (funcall (@ (guile) copy-random-state)
(@ (guile) *random-state*)))
(defun random (&optional limit)
(if (eq limit t)
(setq %random-state
(funcall (@ (guile) random-state-from-platform))))
(funcall (@ (guile) random)
(if (wholenump limit)
limit
(@ (guile) most-positive-fixnum))
%random-state))