summaryrefslogtreecommitdiffstats
path: root/random.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-02 06:57:09 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-03-02 06:57:09 -0800
commit92241abe22d0976d115fbd4caacbf5121d5d5c04 (patch)
tree6336e561ea34d297a25413594a29f1a4359581be /random.tl
parent84ffdada07f03facc90cb7cfc6adacd19025d2c9 (diff)
downloadtamarind-92241abe22d0976d115fbd4caacbf5121d5d5c04.tar.gz
tamarind-92241abe22d0976d115fbd4caacbf5121d5d5c04.tar.bz2
tamarind-92241abe22d0976d115fbd4caacbf5121d5d5c04.zip
Tamarind.
Diffstat (limited to 'random.tl')
-rw-r--r--random.tl8
1 files changed, 8 insertions, 0 deletions
diff --git a/random.tl b/random.tl
new file mode 100644
index 0000000..3b188e4
--- /dev/null
+++ b/random.tl
@@ -0,0 +1,8 @@
+(defun get-urand-num (noctets)
+ (with-stream (s (open-file "/dev/urandom"))
+ (reduce-left (op + (* @1 256) @2) (take noctets (gun (get-byte s))))))
+
+(defun randomize ()
+ (set *random-state* (make-random-state (get-urand-num 8))))
+
+(defun save-random-state ())