From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Brad Collins Newsgroups: gmane.emacs.help Subject: Re: How to create random characters? Date: Fri, 19 Dec 2003 00:30:13 +0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <878ylawh4d.fsf@emptyhost.emptydomain.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1071768348 11676 80.91.224.253 (18 Dec 2003 17:25:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 18 Dec 2003 17:25:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 18 18:25:41 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AX1u9-0005Qc-00 for ; Thu, 18 Dec 2003 18:25:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AX2qr-0006gP-PI for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Dec 2003 13:26:21 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AX2qW-0006fl-CK for help-gnu-emacs@gnu.org; Thu, 18 Dec 2003 13:26:00 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AX2q0-0006Uz-CY for help-gnu-emacs@gnu.org; Thu, 18 Dec 2003 13:25:59 -0500 Original-Received: from [202.183.255.5] (helo=mailgw.cscoms.com) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AX2pz-0006UB-EQ for help-gnu-emacs@gnu.org; Thu, 18 Dec 2003 13:25:27 -0500 Original-Received: from cscoms.com (mail.cscoms.com. [202.183.255.23]) by mailgw.cscoms.com (8.12.8p2/8.12.3) with ESMTP id hBIHNudB064040 for ; Fri, 19 Dec 2003 00:23:57 +0700 (ICT) Original-Received: from KAME.cscoms.com (dial-323.ras-20.bkk.c.cscoms.com [203.170.150.69]) by cscoms.com (8.12.8p2/8.12.3) with ESMTP id hBIHNrDh020599 for ; Fri, 19 Dec 2003 00:23:55 +0700 (GMT) Original-To: help-gnu-emacs In-Reply-To: <878ylawh4d.fsf@emptyhost.emptydomain.de> (Kai Grossjohann's message of "Thu, 18 Dec 2003 10:32:50 +0000") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (windows-nt) X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15421 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15421 Kai Grossjohann writes: > My understanding is that you call (random t) once, eg after Emacs > starts up or when your file is loaded. After this, you can call > (random 42) to obtain numbers in the desired range. > > Does it not work that way? I think it's intended to work that way. > If it doesn't, that might be a bug. I don't think it's a bug... ,----[ Elisp Manual: Random Numbers ] | In Emacs, pseudo-random numbers are generated from a "seed" number. | Starting from any given seed, the `random' function always generates | the same sequence of numbers. Emacs always starts with the same seed | value, so the sequence of values of `random' is actually the same in | each Emacs run! For example, in one operating system, the first call | to `(random)' after you start Emacs always returns -1457731, and the | second one always returns -7692030. This repeatability is helpful for | debugging. | | If you want random numbers that don't always come out the same, | execute `(random t)'. This chooses a new seed based on the current | time of day and on Emacs's process ID number. `---- When I evaluated (random t) I got 80264346 But I need to get a single digit between 0-9 so I used (random 9) But this then uses the same seed every time so the sequence of numbers I'm returned will be repeated every time I restart Emacs. So I needed to limit the number of digits that were returned but at the same time make sure that it will always be random and not start giving me the same numbers I got the day before. I changed to the Clisp random* and things seem to work. Perhaps I've misunderstood this whole thing -- please correct me if I got this wrong... or why it's now working.... it wouldn't be the first time I got something to work the right way for the wrong reasons :) b/ -- Brad Collins Chenla Labs Bangkok, Thailand