Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5779

Re: Specific numbers but in a random sequence

Subject Re: Specific numbers but in a random sequence
Newsgroups comp.sys.acorn.programmer
From Julian Fry <JulianFry@compuserve.com>
Date 2019-06-22 18:05 +0100
Message-ID <17dc36c857.Root@julianfry.orpheusnet.co.uk> (permalink)
References <57c7c5d6c0basura@invalid.addr.uk> <qeji40$7ca$1@dont-email.me> <qel12p$ibq$1@dont-email.me> <57c82fa1bdbasura@invalid.addr.uk>
Organization Orpheus Internet Services

Show all headers | View raw


On 22 Jun 2019 Richard Ashbery  wrote:

> In article <qel12p$ibq$1@dont-email.me>,
>    druck <news@druck.org.uk> wrote:
>> On 21/06/2019 22:27, Gavin Crawford wrote:
>>> Richard Ashbery <basura@invalid.addr.uk> Wrote in message:

> [snip]

> 3,4,5,6,8,9,10,12,15,18,20,24,30,36,45,60,90,120I would like to be
> able to use these variables in a random sequence.

>>> Why not put them into an array and use a random number to choose
>>>   the array index.

>> Yes, and make sure you seed the random number generator, or it may
>> always go through the same pseudo random sequence each time its run.

>> IIRC to seed do RND(-TIME) before any other call to RND.

> Not quite there yet - if I use the following...

> DIM array%(18)
> array%() = 3,4,5,6,8,9,10,12,15,18,20,24,30,36,45,60,90,120
> y = RND(-TIME)
> FOR loop = 1 TO 5
> FOR I% = 0 TO 18
> PRINT array%(RND(I%))
> NEXT I%
> NEXT loop

RND(N) where N>1 (N being an integer) returns a number between 1 and N 
so you are resetting the range every call.
Try RND(18)

-- 
Best wishes

Julian

---
This email has been checked for viruses by AVG.
https://www.avg.com

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

#5770 
  #5771 
    #5772 
      #5773 
      #5774 
        #5775 
          #5778 
            #5780 
              #5781 
                #5782 
                #5783 
                #5784 
                #5786 
                #5787 
                #5788 
                #5785 
        #5776 
        #5777 
        #5779 
  #5789 
    #5790 

csiph-web