|
Suppose you want to get some bytes out of /dev/urandom, and turn it into an integer. For instance, for use as a seed in a call to make-random-state.
(defun get-urand-num (noctets)
(with-stream (s (open-file "/dev/urandom"))
(reduce-left (op + (* @1 256) @2) (take noctets (gun (get-byte s))))))
You pass in how many bytes to read, and get back an integer (arbitrarily large, of course).
Let's break it down:
This message was posted to the following mailing lists: | ||||
---|---|---|---|---|
TXR Users Mailing list info | Nearby messages |
Kaz'z Mailing List Archives adminstered by Kaz | Lurker (version 2.3, substantialy hacked by Kaz). Icon artwork from VisualPharm. |