Why doesn't it accidentally work in the GUI in REBOL?

This very simple script:

REBOL [] view layout [ button "Rand" [alert to-string random 100] ] 

gives the following results:

  • 1st run: 95, 52, 80, 96 ...
  • 2nd launch: 95, 52, 80, 96 ...
  • 3rd run: 95, 52, 80, 96 ...

    ...

This, obviously, is not random, because the same numbers are repeated over and over again.

  • Should I post a bug report on the REBOL website?
  • Is there an easy way to fix it?
+5
source share
2 answers

It looks like you would like to start with a different seed every time you run the script. Typically, the current time is used as a seed in these cases. This has nothing to do with whether you use the GUI or not.

Try:

 REBOL [] random/seed now/precise view layout [ button "Rand" [alert to-string random 100] ] 
+6
source

Do you also restart rebol? Random are sown every time, so it’s not surprising to see the same sequence in that case.

0
source

Source: https://habr.com/ru/post/1202960/


All Articles