zsh-users
 help / color / mirror / code / Atom feed
* rigorously predictable random numbers
@ 2024-05-03  1:23 Ray Andrews
  2024-05-03  3:09 ` Lawrence Velázquez
  0 siblings, 1 reply; 22+ messages in thread
From: Ray Andrews @ 2024-05-03  1:23 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

#!/usr/bin/zsh

echo $RANDOM
var=$( echo $RANDOM )
echo $var

... I run that and get:



3 /aWorking/Zsh/Source/Wk 1 % . test1
23008
3809

3 /aWorking/Zsh/Source/Wk 1 % . test1
3809
768

3 /aWorking/Zsh/Source/Wk 1 % . test1
768
11071

3 /aWorking/Zsh/Source/Wk 1 % . test1
11071
26432

3 /aWorking/Zsh/Source/Wk 1 % . test1
26432
19059

3 /aWorking/Zsh/Source/Wk 1 % . test1
19059
14427

... the result of the first $RANDOM is always exactly the result of the 
second $RANDOM in the previous call to the script.  This might not be as 
unexpected in a function where at least it's the same shell, but a 
script, seems to me, should always have a virginal notion of $RANDOM, 
no?  Yet it remembers the previous result from another shell.  I have 
the vaguest fragment of memory that we discussed this on the list once 
before.


[-- Attachment #2: Type: text/html, Size: 1411 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-05-24 22:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03  1:23 rigorously predictable random numbers Ray Andrews
2024-05-03  3:09 ` Lawrence Velázquez
2024-05-03  3:48   ` Ray Andrews
2024-05-03  4:58     ` Roman Perepelitsa
2024-05-03 13:14       ` Ray Andrews
2024-05-20 17:41       ` Kannan Varadhan
2024-05-20 18:01         ` Roman Perepelitsa
2024-05-20 19:14           ` Kannan Varadhan
2024-05-20 19:40             ` Roman Perepelitsa
2024-05-20 22:56             ` Bart Schaefer
2024-05-21 15:43               ` Mark J. Reed
2024-05-24 22:49             ` Bart Schaefer
2024-05-03  5:40     ` Lawrence Velázquez
2024-05-03 12:51       ` Ray Andrews
2024-05-03 13:36     ` Clinton Bunch
2024-05-03 13:58       ` Ray Andrews
2024-05-03 23:42         ` Lawrence Velázquez
2024-05-04  0:28           ` Bart Schaefer
2024-05-04  1:32             ` Ray Andrews
2024-05-05  6:17             ` Lawrence Velázquez
2024-05-05 15:35               ` Bart Schaefer
2024-05-04  1:19           ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).