Sujet : Re: 100 Random Single Variable Linear Equations
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.awkDate : 07. Dec 2024, 03:21:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vj0bff$2n2c2$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 07.12.2024 02:49, Mike Sanders wrote:
Mike Sanders <porkchop@invalid.foo> wrote:
[...]
SEED = SEED ? SEED : 1
[...]
no, no, what am i thinking, better expressed as:
if (!SEED) SEED = 1
A deliberately chosen seed of 0 gets overwritten?
How about (since you're expecting a number)
if (SEED=="") SEED = 1
or (for good measure) the more general pattern for
an "uninitialized" variable 'var'
if (var=="" && var==0) ... # uninitialized
else ... # initialized (including "" and 0)
But is a seed of 1 "better" than a seed of 0 ?
Both create deterministic random number sequences.
Only srand() (i.e. without argument) creates a
time-depending quasi non-deterministic sequence.
My choice would probably be
if (var=="" && var==0) srand() # random start
else srand(var) # deterministic
to have both options.
Janis