ListStridedReorder
Revision as of 18:53, 18 December 2015 by Mizu Melody (talk | contribs)
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 = -stride;
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(strides > ++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])));
}
}