-- CREATE FUNCTION
fn RandomSequence Num=(
theSequence = for i=1 to Num collect i -- Create Initial Sequence
theResult =#() -- Create empty array for the result
-- Loop
range = theSequence.count+1
for j=1 to theSequence.count do
(
range -=1
rand = random 1 range -- Create random start with higher range value until empty
append theResult theSequence[rand] -- Insert to the Result
index = finditem theSequence theSequence[rand] -- Check the index of result in thesequence
deleteitem theSequence index -- Then delete item in theSequence with indexed number
) -- End Loop
theResult -- Output the result
)
RandomSequence 10 -- Call the function
Every time you execute this function it will always generate new random number in sequence without any repetition. You can try use this number to manipulating object properties, transform, etc.
No comments:
Post a Comment