Random but unique

Rob Cozens rcozens at pon.net
Sat Jan 11 16:34:27 EST 2003


>Maybe you could go at it backwards

Bravo, Jim!

It's an issue programmers have faced since Day One, and you are the 
first person to my knowledge to suggest this.

But note that your solution has the opposite performance curve of 
mine:  it works efficiently when the number of lines to be selected 
is close to the number of lines to select from.

Perhaps a tuned-for-performance function would conditionally utilize 
any of the three approaches:

function randomList vNumToChoose, at vChooseFrom
    get trunc((vNumToChoose*100)/(the number of lines of vChooseFrom))
    if it < 34 then useRobsMethod
    else if it < 68 then useDarsMethod
    else useJimsMethod
end randomList
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list