From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA08517 for caml-redistribution; Fri, 28 May 1999 17:07:02 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA02843 for ; Thu, 27 May 1999 22:07:21 +0200 (MET DST) Received: from nestor (tntstet7-232.abo.wanadoo.fr [164.138.90.232]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id WAA11284; Thu, 27 May 1999 22:07:13 +0200 (MET DST) Received: from nestor [127.0.0.1] (mt) by nestor with esmtp (Exim 2.05 #1 (Debian)) id 10ykw0-0001U5-00; Tue, 29 Jun 1999 01:35:32 +0200 X-Mailer: exmh version 2.0.2 2/24/98 (debian) To: Damien Doligez cc: caml-list@inria.fr Subject: Re: Random.int on non unix platform In-reply-to: Your message of "Wed, 26 May 1999 14:07:19 +0200." <199905261207.OAA17846@tobago.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Date: Tue, 29 Jun 1999 01:35:31 +0300 From: Martin Quinson Message-Id: Sender: weis > >From: Martin Quinson > = > >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 sin= ce the > beginning of execution. So, if this call is at the begining of the programm, it will allways gene= rate = 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 al= one = 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'e= st = 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 t= out = seul comme un grand de s'initialiser sans demander a l'utilisateur de le = faire. (dans une prochaine version ?) Merci & thanks, Martin.