Random number generator (device): Difference between revisions

Content added Content deleted
(Add Factor example)
(→‎{{header|Factor}}: use a better method)
Line 238: Line 238:


=={{header|Factor}}==
=={{header|Factor}}==
Factor has good support for switching between different random number generators. <code>with-system-random</code> is a combinator that encapsulates the task of using a system RNG (/dev/random in the case of GNU/Linux).
<lang factor>USE: io.encodings.binary
<lang factor>USE: random
"/dev/urandom" binary [ read1 ] with-file-reader .</lang>
[ random-32 ] with-system-random .</lang>


=={{header|Forth}}==
=={{header|Forth}}==