Difference between revisions of "LlListRandomize"

From Second Life Wiki
Jump to navigation Jump to search
Line 26: Line 26:
|helpers
|helpers
|also_header
|also_header
|also_functions
|also_functions=*{{LSLG|llListSort}}
|also_tests
|also_tests
|also_articles
|also_articles
Line 39: Line 39:
|cat3
|cat3
|cat4
|cat4
|location=lsa_randomize: 'linden\indra\lscript\lscript_library\lscript_alloc.cpp'
|location=lsa_randomize(): 'linden\indra\lscript\lscript_library\lscript_alloc.cpp'
}}
}}

Revision as of 08:49, 13 February 2007

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 straws = ["long", "long", "long", "short"];
list shuffled = llListRandomize(straws, 1);
llSay(0, llList2CSV(bar));

See Also

Functions

Deep Notes

Source

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

Signature

function list llListRandomize( list src, integer stride );