Random but unique

Cubist at aol.com Cubist at aol.com
Sat Jan 11 16:20:01 EST 2003


sez dar scott:
>> Use a copy of the variable and remove values as pulled from the
>> variable?

sez tkuypers at pandora.be
>Could you explain this? Removing values is not what I need, I need these
>values, or am I missing something...

   Here is a function that takes a return-delimited list of values; picks a 
random line from the list; deletes the value that was picked; and returns the 
picked value plus the remainder of the list.

function PickNZap ListOValues
  put the number of lines in ListOValues into Fred
  put the random of Fred into George
  put line George of ListOValues into DisValue
  delete line George of ListOValues
  return DisValue & return & ListOValues
end PickNZap

   The first item in the returned list is the randomly-selected item from 
said list. The main reason I did it that way is that I'm not quite sure if 
it's possible to return *two* results from a function...
   Hope this helps...



More information about the use-livecode mailing list