[mercury-users] Converting time_t to int using common library?
Peter Schachte
schachte at csse.unimelb.edu.au
Wed Feb 14 13:14:33 AEDT 2007
>> % random.init(RS, !IO): creates a supply of random numbers RS
>> % using a sensible default seed (e.g., on POSIX it will use
>> % the number of seconds since the unix epoch.)
>> %
>> :- pred random.init(random.supply::uo, io::di, io::uo) is det.
>>
>> % random.init(RS): creates a supply of random numbers RS
>> % using a sensible default seed (e.g., on POSIX it will use
>> % the number of seconds since the unix epoch.) This function
>> % differs from the previous predicate in that it only determines
>> % the 'sensible default seed' when first evaluated, and
>> % thereafter uses that same seed.
>> %
One problem with this is that if you call it twice in rapid succession, it will
probably give you the same random supply. It would probably be better for
subsequent calls to this to us some function (e.g., xor) of the time and the
previously generated seed.
--
Peter Schachte Computer science is not about computers any more
schachte at cs.mu.OZ.AU than astronomy is about telescopes.
www.cs.mu.oz.au/~schachte/ -- EW Dijkstra
Phone: +61 3 8344 1338
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list