Difference between revisions of "ListStridedReorder"
Jump to navigation
Jump to search
(Created page with "<lsl> list ListStridedReorderContents(list src, list order) { //change the order that the elements in the groups are arranged integer stride = llGetListLength(order); integer …") |
m |
||
Line 1: | Line 1: | ||
<lsl> | <lsl>list ListStridedReorderContents(list src, list order) { | ||
list ListStridedReorderContents(list src, list order) { | //change the order that the elements in the groups are arranged | ||
integer stride = llGetListLength(order); | |||
integer len = llGetListLength(src); | |||
integer strides = len / stride; | |||
list temp = []; | |||
list out = []; | |||
integer i = -strides; | |||
do{ | |||
temp += llList2ListStrided(llList2List(src, llList2Integer(order, i), -1), 0, -1, stride); | |||
}while(++i); | |||
do{ | |||
out += llList2ListStrided(llList2List(temp, i, -1), 0, -1, strides); | |||
}while(stride > ++i); | |||
return out; | |||
} | } | ||
list ListStridedReorderStrides(list src, list order) { | list ListStridedReorderStrides(list src, list order) { | ||
//change the order that the groups are arranged | |||
integer strides = llGetListLength(order); | |||
integer len = llGetListLength(src); | |||
integer stride = len / strides; | |||
list temp = []; | |||
list out = []; | |||
integer i = 0; | |||
do | |||
temp += llList2ListStrided(llList2List(src, i, -1), 0, -1, stride); | |||
while(strides > ++i); | |||
i = -stride; | |||
do | |||
out += llList2ListStrided(llList2List(temp, llList2Integer(order, i), -1), 0, -1, strides); | |||
while(++i); | |||
return out; | |||
} | } | ||
list ListStridedReorderContentsAndStrides(list src, list element_order, list stride_order) { | list ListStridedReorderContentsAndStrides(list src, list element_order, list stride_order) { | ||
integer stride = llGetListLength(element_order); | |||
integer strides = llGetListLength(stride_order); | |||
list temp = []; | |||
list out = []; | |||
integer i = -strides; | |||
do | |||
temp += llList2ListStrided(llList2List(src, llList2Integer(element_order, i), -1), 0, -1, stride); | |||
while(++i); | |||
i = -stride; | |||
do | |||
out += llList2ListStrided(llList2List(temp, llList2Integer(stride_order, i), -1), 0, -1, strides); | |||
while(++i); | |||
return out; | |||
} | } | ||
Line 54: | Line 53: | ||
default | default | ||
{ | { | ||
state_entry(){ | |||
llOwnerSay(llList2CSV(ListStridedReorderContents([0,1,2, 0,1,2, 0,1,2], [1,2,0]))); | |||
llOwnerSay(llList2CSV(ListStridedReorderStrides([0,1,2, 3,4,5, 6,7,8], [1,2,0]))); | |||
llOwnerSay(llList2CSV(ListStridedReorderContentsAndStrides([0,1,2, 3,4,5, 6,7,8], [1,2,0], [1,2,0]))); | |||
} | |||
} | }</lsl> | ||
</lsl> |
Revision as of 11:34, 23 January 2012
<lsl>list ListStridedReorderContents(list src, list order) {
//change the order that the elements in the groups are arranged integer stride = llGetListLength(order); integer len = llGetListLength(src); integer strides = len / stride; list temp = []; list out = []; integer i = -strides; do{ temp += llList2ListStrided(llList2List(src, llList2Integer(order, i), -1), 0, -1, stride); }while(++i); do{ out += llList2ListStrided(llList2List(temp, i, -1), 0, -1, strides); }while(stride > ++i); return out;
}
list ListStridedReorderStrides(list src, list order) {
//change the order that the groups are arranged integer strides = llGetListLength(order); integer len = llGetListLength(src); integer stride = len / strides; list temp = []; list out = []; integer i = 0; do temp += llList2ListStrided(llList2List(src, i, -1), 0, -1, stride); while(strides > ++i); i = -stride; do out += llList2ListStrided(llList2List(temp, llList2Integer(order, i), -1), 0, -1, strides); while(++i); return out;
}
list ListStridedReorderContentsAndStrides(list src, list element_order, list stride_order) {
integer stride = llGetListLength(element_order); integer strides = llGetListLength(stride_order); list temp = []; list out = []; integer i = -strides; do temp += llList2ListStrided(llList2List(src, llList2Integer(element_order, i), -1), 0, -1, stride); while(++i); i = -stride; do out += llList2ListStrided(llList2List(temp, llList2Integer(stride_order, i), -1), 0, -1, strides); while(++i); return out;
}
default
{
state_entry(){ llOwnerSay(llList2CSV(ListStridedReorderContents([0,1,2, 0,1,2, 0,1,2], [1,2,0]))); llOwnerSay(llList2CSV(ListStridedReorderStrides([0,1,2, 3,4,5, 6,7,8], [1,2,0]))); llOwnerSay(llList2CSV(ListStridedReorderContentsAndStrides([0,1,2, 3,4,5, 6,7,8], [1,2,0], [1,2,0]))); }
}</lsl>