Hello Nigel.
I don’t think it is doable to outmatch the random number generator of standard additions, with regard to speed, and I’m not sure that it in any case will be faster in a quick sort handler. However, it can be advantageous with an alternative sequence somewhere, for instance for use in a secondary hash function.
Here is a little nifty generator by the way, a litle bit faster than random number, not fast enough for quicksort.
script pseudo
-- pure multiplicative random generator.
-- Its faster most of the time than Standard Additions random number (10000 runs).
-- it has been proved that the sequence doesn't repeat itself before 2^31 -2 calls have been made.
-- yet: No warranties about anything.
-- Rosen "Discrete Mathematics" p. 207
property x0 : 3
property rmod : 2 ^ 31 - 1
property multiplier : 7 ^ 5
on rand()
set x0 to (multiplier * x0) mod rmod
return (x0 / 1.0E+9)
end rand
on init()
rand()
end init
end script
set tstlist to {}
set t0 to (current date)
pseudo's init()
repeat 10000 times
if 1 = 1 then
set end of tstlist to (((pseudo's rand()) * 100) mod 100 div 1 + 1)
else
set end of tstlist to (random number) * 100 mod 100 div 1 + 1
end if
end repeat
set res to ((current date) - t0) / 1000
set newlist to sortlist tstlist with ascending
-- Satimage.osax
log "res :" & res
set f to 1
set min to 100
set max to 0
set ctr to 1
repeat with i from 1 to 10000
if item i of newlist ≠f then
log "num " & f & " f: " & ctr
if ctr < min then set min to ctr
if ctr > max then set max to ctr
set ctr to 1
set f to item i of newlist
else
set ctr to ctr + 1
end if
end repeat
log "min: " & min & " max:" & max