summaryrefslogtreecommitdiffstats
path: root/random.tl
diff options
context:
space:
mode:
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 ())