mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
elisp rng
* module/language/elisp/boot.el (random): New function.
This commit is contained in:
parent
43ff6804d6
commit
52d2472441
1 changed files with 15 additions and 0 deletions
|
@ -596,3 +596,18 @@
|
|||
|
||||
(defun prin1-to-string (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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue