Random number generator (device): Difference between revisions

Add Mercury
(Add Mercury)
Line 958:
<pre>{355587317, -869860319, -91421859, 1605907693, 101463390, 891823090,
-531713717, -1038608428, 1717313407, 674189312}</pre>
 
=={{header|Mercury}}==
For versions of Mercury greater than 20.06, the standard library module <tt>random.system_rng</tt> provides access to a platform specific random data source.<br />
 
Generates unsigned 32-bit integers.
 
<lang mercury>:- module random_number_device.
:- interface.
 
:- import_module io.
:- pred main(io::di, io::uo) is det.
 
:- implementation.
:- import_module maybe, random, random.system_rng, require.
 
main(!IO) :-
open_system_rng(MaybeRNG, !IO),
(
MaybeRNG = ok(RNG),
random.generate_uint32(RNG, U32, !IO),
io.print_line(U32, !IO),
close_system_rng(RNG, !IO)
;
MaybeRNG = error(ErrorMsg),
io.stderr_stream(Stderr, !IO),
io.print_line(Stderr, ErrorMsg, !IO),
io.set_exit_status(1, !IO)
).</lang>
 
=={{header|NetRexx}}==
Anonymous user