Difference between revisions of "List2ListLoop"
BETLOG Hax (talk | contribs) (New page: Tired of llList2List automatically reordering your output when your negative index comes before a positive index? eg: <lsl> list gData = ["A","B","C","D","E"]; .... llList2Li...) |
BETLOG Hax (talk | contribs) m |
||
Line 1: | Line 1: | ||
Tired of llList2List automatically reordering your output | Tired of llList2List automatically reordering your output? | ||
eg: | eg: | ||
<lsl> | <lsl> | ||
list gData = ["A","B","C","D","E"]; | list gData = ["A","B","C","D","E"]; | ||
// indexes 0, 1, 2, 3, 4 | |||
// negative indexes -5, -4, -3, -2, -1 | |||
.... | .... | ||
llList2List(gData,4, -3) = A, B, C, E // | llList2List(gData,4, -3) = A, B, C, E // not really intuitive, output is automatically rearranged, and is thereby NOT what was requested. | ||
// what I really wanted was E, A, B, C | |||
// or possibly E, D, C | |||
llList2List(gData,3, -2) = D // ok | llList2List(gData,3, -2) = D // ok | ||
llList2List(gData,2, -1) = C, D, E // ok | llList2List(gData,2, -1) = C, D, E // ok | ||
Line 11: | Line 15: | ||
llList2List(gData,0, 3) = A, B, C, D // ok | llList2List(gData,0, 3) = A, B, C, D // ok | ||
llList2List(gData,-1, 2) = A, B, C, E // not really intuitive, output is automatically rearranged, and is thereby NOT what was requested. | llList2List(gData,-1, 2) = A, B, C, E // not really intuitive, output is automatically rearranged, and is thereby NOT what was requested. | ||
// what I really wanted was E, A, B, C | |||
// or possibly E, D, C | |||
</lsl> | </lsl> | ||
This sucks in situations where you want your data in a circular loop. (or when you expect llList2List to actually give you what you asked for) | This sucks in situations where you want your data in a circular loop. (or when you expect llList2List to actually give you what you asked for), | ||
and can be particularly problematic when attempting to extract a small window of data, and suddenly a LARGE window of data is returned..in the wrong sequence. | |||
<lsl> | <lsl> | ||
//========================================================================= | //========================================================================= |
Revision as of 05:56, 6 June 2009
Tired of llList2List automatically reordering your output?
eg: <lsl> list gData = ["A","B","C","D","E"]; // indexes 0, 1, 2, 3, 4 // negative indexes -5, -4, -3, -2, -1 ....
llList2List(gData,4, -3) = A, B, C, E // not really intuitive, output is automatically rearranged, and is thereby NOT what was requested.
// what I really wanted was E, A, B, C // or possibly E, D, C
llList2List(gData,3, -2) = D // ok llList2List(gData,2, -1) = C, D, E // ok llList2List(gData,1, 4) = B, C, D, E // ok llList2List(gData,0, 3) = A, B, C, D // ok llList2List(gData,-1, 2) = A, B, C, E // not really intuitive, output is automatically rearranged, and is thereby NOT what was requested.
// what I really wanted was E, A, B, C // or possibly E, D, C </lsl> This sucks in situations where you want your data in a circular loop. (or when you expect llList2List to actually give you what you asked for), and can be particularly problematic when attempting to extract a small window of data, and suddenly a LARGE window of data is returned..in the wrong sequence. <lsl> //========================================================================= // BETLOG Hax // Efficiency modifications by Nomad Padar // 20090606 //========================================================================= // ---LICENCE START--- // http://creativecommons.org/licenses/by-sa/3.0/ // http://creativecommons.org/licenses/LGPL/2.1/ // ie: Attribution licence: // Give me credit by leaving it in the script I created. // And/Or supply my original script with your modified version. // ---LICENCE END--- //========================================================================= // //---------------------------------- list f_list2ListLoop(list data, integer begin, integer end)//less legible, same thing { if ((end=(end+gCount)%gCount)<(begin=(begin+gCount)%gCount))
return llList2List(data, begin,-1)+llList2List(data, 0, end); return llList2List(data, begin, end);
} //---------------------------------- list f_list2ListLoop(list data, integer begin, integer end)//more legible, same thing { begin = (begin+gCount)%gCount;
end = (end+gCount)%gCount; if (end<begin) return llList2List(data, begin,-1)+llList2List(data, 0, end); return llList2List(data, begin, end);
} //---------------------------------- </lsl>