Re: 100 Random Single Variable Linear Equations

Liste des GroupesRevenir à cl awk 
Sujet : Re: 100 Random Single Variable Linear Equations
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.awk
Date : 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


Date Sujet#  Auteur
6 Dec 24 * 100 Random Single Variable Linear Equations23Mike Sanders
6 Dec 24 +* Re: 100 Random Single Variable Linear Equations19Mike Sanders
6 Dec 24 i`* Re: 100 Random Single Variable Linear Equations18Janis Papanagnou
6 Dec 24 i +* Re: 100 Random Single Variable Linear Equations3Janis Papanagnou
7 Dec 24 i i+- Re: 100 Random Single Variable Linear Equations1Mike Sanders
7 Dec 24 i i`- Re: 100 Random Single Variable Linear Equations1Mike Sanders
6 Dec 24 i `* Re: 100 Random Single Variable Linear Equations14Mike Sanders
6 Dec 24 i  +* Re: 100 Random Single Variable Linear Equations3Janis Papanagnou
7 Dec 24 i  i`* Re: 100 Random Single Variable Linear Equations2Christian Weisgerber
7 Dec 24 i  i `- Re: 100 Random Single Variable Linear Equations1Mike Sanders
6 Dec 24 i  +* Re: 100 Random Single Variable Linear Equations3Keith Thompson
7 Dec 24 i  i`* Re: 100 Random Single Variable Linear Equations2Mike Sanders
7 Dec 24 i  i `- Re: 100 Random Single Variable Linear Equations1Mike Sanders
7 Dec 24 i  `* Re: 100 Random Single Variable Linear Equations7Mike Sanders
7 Dec 24 i   `* Re: 100 Random Single Variable Linear Equations6Mike Sanders
7 Dec 24 i    `* Re: 100 Random Single Variable Linear Equations5Janis Papanagnou
8 Dec 24 i     `* Re: 100 Random Single Variable Linear Equations4Mike Sanders
8 Dec 24 i      `* Re: 100 Random Single Variable Linear Equations3Janis Papanagnou
9 Dec 24 i       `* Re: 100 Random Single Variable Linear Equations2Mike Sanders
9 Dec 24 i        `- Re: 100 Random Single Variable Linear Equations1Janis Papanagnou
8 Dec 24 +* Re: 100 Random Single Variable Linear Equations2Mike Sanders
8 Dec 24 i`- Re: 100 Random Single Variable Linear Equations1Mike Sanders
8 Dec 24 `- Re: 100 Random Single Variable Linear Equations1Mike Sanders

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal