Difference between revisions of "ListStridedReorder"

From Second Life Wiki
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
//change the order that the elements in the groups are arranged
    integer stride = llGetListLength(order);
integer stride = llGetListLength(order);
    integer len = llGetListLength(src);
integer len = llGetListLength(src);
    integer strides = len / stride;
integer strides = len / stride;
    list temp = [];
list temp = [];
    list out = [];
list out = [];
    integer i = -strides;
integer i = -strides;
    do{
do{
        temp += llList2ListStrided(llList2List(src, llList2Integer(order, i), -1), 0, -1, stride);
temp += llList2ListStrided(llList2List(src, llList2Integer(order, i), -1), 0, -1, stride);
    }while(++i);
}while(++i);
    do{
do{
        out += llList2ListStrided(llList2List(temp, i, -1), 0, -1, strides);
out += llList2ListStrided(llList2List(temp, i, -1), 0, -1, strides);
    }while(stride > ++i);
}while(stride > ++i);
    return out;
return out;
}
}


list ListStridedReorderStrides(list src, list order) {
list ListStridedReorderStrides(list src, list order) {
//change the order that the groups are arranged
    //change the order that the groups are arranged
integer strides = llGetListLength(order);
    integer strides = llGetListLength(order);
integer len = llGetListLength(src);
    integer len = llGetListLength(src);
integer stride = len / strides;
    integer stride = len / strides;
list temp = [];
    list temp = [];
list out = [];
    list out = [];
integer i = 0;
    integer i = 0;
do
    do
temp += llList2ListStrided(llList2List(src, i, -1), 0, -1, stride);
        temp += llList2ListStrided(llList2List(src, i, -1), 0, -1, stride);
while(strides > ++i);
    while(strides > ++i);
i = -stride;
    i = -stride;
do
    do
out += llList2ListStrided(llList2List(temp, llList2Integer(order, i), -1), 0, -1, strides);
        out += llList2ListStrided(llList2List(temp, llList2Integer(order, i), -1), 0, -1, strides);
while(++i);
    while(++i);
return out;
    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 stride = llGetListLength(element_order);
integer strides = llGetListLength(stride_order);
    integer strides = llGetListLength(stride_order);
list temp = [];
    list temp = [];
list out = [];
    list out = [];
integer i = -strides;
    integer i = -strides;
do
    do
temp += llList2ListStrided(llList2List(src, llList2Integer(element_order, i), -1), 0, -1, stride);
        temp += llList2ListStrided(llList2List(src, llList2Integer(element_order, i), -1), 0, -1, stride);
while(++i);
    while(++i);
i = -stride;
    i = -stride;
do
    do
out += llList2ListStrided(llList2List(temp, llList2Integer(stride_order, i), -1), 0, -1, strides);
        out += llList2ListStrided(llList2List(temp, llList2Integer(stride_order, i), -1), 0, -1, strides);
while(++i);
    while(++i);
return out;
    return out;
}
}


Line 54: Line 53:
default
default
{
{
state_entry(){
    state_entry(){
llOwnerSay(llList2CSV(ListStridedReorderContents([0,1,2, 0,1,2, 0,1,2], [1,2,0])));//1, 2, 0, 1, 2, 0, 1, 2, 0
        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])));//3, 4, 5, 6, 7, 8, 0, 1, 2
        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])));//4, 5, 3, 7, 8, 6, 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>