From: Martin Quinson <mquinson@zeppelin-cb.de>
To: Damien Doligez <Damien.Doligez@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: Random.int on non unix platform
Date: Tue, 29 Jun 1999 01:35:31 +0300 [thread overview]
Message-ID: <E10ykw0-0001U5-00@nestor> (raw)
In-Reply-To: Your message of "Wed, 26 May 1999 14:07:19 +0200." <199905261207.OAA17846@tobago.inria.fr>
> >From: Martin Quinson <mquinson@zeppelin-cb.de>
>
> >How can I write this without the unix library ?
> >
> >Random.init (int_of_float (Unix.time ()));;
>
> You can do:
>
> Random.init (int_of_float (Sys.time ()));;
>
> or you can input a random seed from the user and give it as argument
> to Random.init.
(francais en bas)
hmmm. from htmlman/module sys :
> val time: unit -> float
>
> Return the processor time, in seconds, used by the program since the
> beginning of execution.
So, if this call is at the begining of the programm, it will allways generate
the same number (or almost). from the random.ml source code :
(* Simple initialisation. The seed is an integer.
Two seeds that are close enough will not produce uncorrelated
pseudo-random sequences.
*)
And I really dislike the second solution...
Maybe would it be possible to make the module Random initialize itself alone
before the first call, in the next release...
[en francais]
J'aimerais initialiser le generateur aléatoire de nombre sans utiliser la
librairie Unix. Dans d'autres langage, j'ai l'habitude d'utiliser l'heure pour
ca, mais, apparament, c'est impossible sans la librairie Unix (ce qui n'est
pas portable, oblige a recompiler le top-level et complique la ligne de
compilation des compilateurs)
Quant à l'idée de demander une graine à l'utilisateur, je trouve ca un peu
préhistorique, comme approche. ;)
A mon avis, le plus simple serait encore que le module Random se charge tout
seul comme un grand de s'initialiser sans demander a l'utilisateur de le faire.
(dans une prochaine version ?)
Merci & thanks,
Martin.
next prev parent reply other threads:[~1999-05-28 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-05-26 12:07 Damien Doligez
1999-06-28 22:35 ` Martin Quinson [this message]
1999-05-30 19:44 ` Events, method iterator Ubik
1999-06-01 9:39 ` Jerome Vouillon
1999-06-27 15:53 Random.int on non unix platform Martin Quinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E10ykw0-0001U5-00@nestor \
--to=mquinson@zeppelin-cb.de \
--cc=Damien.Doligez@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox