Difference between revisions of "LlListRandomize"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|sort=ListRandomize
|sort=ListRandomize|func=llListRandomize
|func=llListRandomize
|func_id=197|func_sleep=0.0|func_energy=10.0
|func_id=197
|func_sleep=0.0
|func_energy=10.0
|p1_type=list
|p1_type=list
|p1_name=src
|p1_name=src
Line 12: Line 9:
|p2_desc=How many list entries to keep next to each other during the randomization.
|p2_desc=How many list entries to keep next to each other during the randomization.
|return_type=list
|return_type=list
|return_text=which is a randomized permutation of src.
|return_text=which is a randomized permutation of '''src'''.
|spec=
|spec=
When you want to randomize the position of every list element, specify a stride of 1.
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.
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.
Conceptually, the algorithm selects src.length()/stenride buckets, and th for each bucket swaps it the contents with another bucket.
|caveats=
|caveats=
|examples=
|examples=
Line 26: Line 23:
llSay(0, llList2CSV(bar));
llSay(0, llList2CSV(bar));
</pre>
</pre>
|func_helpers
|constants
|also
|helpers
|also_header
|also_functions
|also_tests
|also_articles
|also_footer
|notes
|notes
|mode
|deprecated
|permission
|negative_index
|cat1=List
|cat2
|cat3
|cat4
|location=linden\indra\lscript\lscript_library\lscript_alloc.cpp
}}
}}
[[Category:LSL_List]]

Revision as of 08:38, 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()/stenride buckets, and th 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

Source

linden\indra\lscript\lscript_library\lscript_alloc.cpp

Signature

function list llListRandomize( list src, integer stride );