Deutsch   English   Français   Italiano  
<vj0bff$2n2c2$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.awk
Subject: Re: 100 Random Single Variable Linear Equations
Date: Sat, 7 Dec 2024 03:21:34 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <vj0bff$2n2c2$1@dont-email.me>
References: <vits2o$240vr$1@dont-email.me> <vitvta$24sm3$1@dont-email.me>
 <viurhe$2bces$1@dont-email.me> <viuunp$2c1ev$1@dont-email.me>
 <vivsd0$2jij8$1@dont-email.me> <vj09j9$2mf7i$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 07 Dec 2024 03:21:35 +0100 (CET)
Injection-Info: dont-email.me; posting-host="bcd19ac4cfc6094ca73c8e05b6530ac7";
	logging-data="2853250"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19iNBO+TTyiysF3eufNEOEm"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
Cancel-Lock: sha1:wDBp7hQ1qN10ArDLVK4FzHWZhU8=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vj09j9$2mf7i$2@dont-email.me>
Bytes: 2114

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