Difference between revisions of "LlListRandomize"
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
{{LSL_Function | {{LSL_Function | ||
|sort= | |sort=ListRandomize | ||
|func=llListRandomize | |func=llListRandomize | ||
|func_id=197 | |func_id=197 |
Revision as of 12:23, 12 February 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: list llListRandomize( list src, integer stride );197 | Function ID |
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.lengh()/stride buckets, and then for each bucket swaps it the contents with another bucket.
Caveats
Examples
list straws = ["long", "long", "long", "short"]; list shuffled = llListRandomize(straws, 1); llSay(0, llList2CSV(bar));