help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create random characters?


From: Harald Maier
Subject: Re: How to create random characters?
Date: Thu, 18 Dec 2003 19:30:50 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Brad Collins <brad@studiojungle.net> writes:

> Kai Grossjohann <kai@emptydomain.de> writes:

> ,----[ 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.

Then you have not called again the seed function of random (random
t). I am using the elisp random function all the time to hear music
from my music library in a random fashion. And I do not get always the
same songs. They are always different.

Harald


reply via email to

[Prev in Thread] Current Thread [Next in Thread]