diff options
author | BT Templeton <bpt@hcoop.net> | 2012-03-07 20:09:21 -0500 |
---|---|---|
committer | BT Templeton <bpt@hcoop.net> | 2012-03-08 17:08:30 -0500 |
commit | 52d2472441891cbb85ec23d16e685d91c5ed8bfd (patch) | |
tree | 03b6d7a6e689e572f24a993a8aa43971065bde1b /module | |
parent | 43ff6804d64f4db680961849a12decd34e571416 (diff) | |
download | guile-52d2472441891cbb85ec23d16e685d91c5ed8bfd.tar.gz |
elisp rng
* module/language/elisp/boot.el (random): New function.
Diffstat (limited to 'module')
-rw-r--r-- | module/language/elisp/boot.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/module/language/elisp/boot.el b/module/language/elisp/boot.el index adafe4d29..53711e1f6 100644 --- a/module/language/elisp/boot.el +++ b/module/language/elisp/boot.el @@ -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)) |