Random but unique
tkuypers at pandora.be
tkuypers at pandora.be
Sat Jan 11 15:52:01 EST 2003
:-))
Thanks, this got me thinking and solved the problem... Didn't think of
removing the found line of my first var.
So simple, so easy...
Thanks!
Ton
> From: Dar Scott <dsc at swcp.com>
> Reply-To: use-revolution at lists.runrev.com
> Date: Sat, 11 Jan 2003 13:21:27 -0700
> To: use-revolution at lists.runrev.com
> Subject: Re: Random but unique
>
>
> On Saturday, January 11, 2003, at 12:52 PM, tkuypers at pandora.be wrote:
>
>> Could you explain this? Removing values is not what I need, I need
>> these
>> values, or am I missing something...
>>>
>>> Use a copy of the variable and remove values as pulled from the
>>> variable?
>
> Off the top of my head:
>
> -- function to return n random lines from a list
> -- with no line selected more than once
> function getUniqueRandomLines theList n
> local theLines, pick
> put empty into theLines
> if n > the number of lines in theList then throw "Can't get random
> lines"
> repeat for n times
> put random( the number of lines in theList) into pick
> put line pick & lineFeed after theLines
> delete line pick of theList
> end repeat
> return theLines
> end if
>
> This may not fit your exact needs, but perhaps it might inspire
> something that will. This may have a speed problem with long lists, so
> I'm not completely happy with this.
>
> Or did I miss something about this?
>
> (I don't think "any" will work for the above method, unless some other
> method is used to remove the line.)
>
> Dar Scott
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list