Re: Random function

new topic     » goto parent     » topic index » view thread      » older message » newer message

Aku,

Random shuffle was already discussed here several times. 
The function below does the trick. jiri

function shuffle(sequence s)
    object temp
    integer j

    for i = length(s) to 2 by -1 do
        j = rand(i)
        temp = s[j]
        s[j] = s[i]
        s[i] = temp
    end for
    return s
end function


----- Original Message ----- 
From: <aku at inbox.as>
To: "EUforum" <EUforum at topica.com>
Sent: Friday, March 09, 2001 1:33 AM
Subject: Random function


> How I can make function that accept sequence as input
> for example {1,2,3,4,5,6,7,7.5,10,50,100} and output
> that sequence but in random order such as
> {5,100,4,7.5,7,1,2,50,10,3,6} as efficient as possible?
> 
> Thanks!
> 
> 
> 
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu