Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: silly, but what's wrong?

From: larry:ecotope at: 30-Jul-2001 18:05

Hi Tom In most languages RANDOM is by default seeded with a dynamic value derived from the system clock. In REBOL, RANDOM is by default set with a seed of 1. So the sequence of values returned by RANDOM is always the same (i.e., the first use of RANDOM with a given argument always produces the same value).
>> random 100
== 95
>> random 100
== 52
>> random/seed 1 >> random 100
== 95 So the first value returned for random 100 is always 95 and the second is always 52. Setting the seed back to one starts the sequence over. If you want RANDOM to produce a different sequence of values every time the code runs, you need to initialize the seed with a dynamic value like the system time.
>> random/seed now >> random 100
== 71
>> random/seed now >> random 100
== 3 HTH -Larry