llListRandomize

From Second Life Wiki
Revision as of 06:44, 2 October 2007 by Huney Jewell (talk | contribs) (Example won't compile)
Jump to navigation Jump to search

Summary

Function: list llListRandomize( list src, integer stride );
0.0 Forced Delay
10.0 Energy

Returns a list which is a randomized permutation of src.

• list src A list you want to randomize.
• integer stride How many list entries to keep next to each other during the randomization.

Specification

When you want to randomize the position of every list element, specify a stride of 1.

If the stride is not a factor of the list length, the src list is returned. In other words, src.length() % stride must be 0.

Conceptually, the algorithm selects src.length()/stride buckets, and then for each bucket swaps it the contents with another bucket.

Examples

list dice = ["2", "4", "1", "6", "3", "5"];
list shuffled = llListRandomize(dice, 1);
llOwnerSay(llList2CSV(shuffled));

See Also

Functions

•  llListSort
•  llFrand

Deep Notes

Source

lsa_randomize(): 'linden\indra\lscript\lscript_library\lscript_alloc.cpp'

Signature

function list llListRandomize( list src, integer stride );