Difference between revisions of "LlListRandomize"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
{{LSLFunctionAll|func_id=197|func_sleep=0.0|func_energy=10.0|func=llListRandomize|return_type=list|p1_type=list|p1_name=src|p2_type=integer|p2_name=stride|func_footnote=Returns a randomized list of blocks of size stride|return_text|spec|caveats|examples|helpers|related|also|notes}}[[Category:LSL_Functions]][[Category:LSL_Stub]]
{{LSL_Function
|sort=listrandomize
|func=llListRandomize
|func_id=???
|func_sleep=0.0
|func_energy=10.0
|p1_type=list
|p1_name=src
|p1_desc=A list you want to randomize.
|p2_type=integer
|p2_name=stride
|p2_desc=How many list entries to keep next to each other during the randomization.
|return_type=list
|return_text=which is a randomized permutation of src.
|spec=
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=
<pre>
list straws = ["long", "long", "long", "short"];
list shuffled = llListRandomize(straws, 1);
llSay(0, llList2CSV(bar));
</pre>
|func_helpers
|also
|notes
}}

Revision as of 16:28, 31 January 2007

Summary

Function: list llListRandomize( list src, integer stride );

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.

Examples

list straws = ["long", "long", "long", "short"];
list shuffled = llListRandomize(straws, 1);
llSay(0, llList2CSV(bar));

Deep Notes

Search JIRA for related Issues

Signature

function list llListRandomize( list src, integer stride );