Don't click here unless you want to be banned.

LSL Wiki : llList2ListStrided

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl814.us.archive.org
list llList2ListStrided(list src, integer start, integer end, integer stride)

Copies the strided slice of the list from start to end.

llList2ListStrided returns a list consisting of every stride'th element from src that is between element start and element end.

list src = ["a", 1, 2, "b", 3, 4, "c", 5, 6, "d", 7, 8];

llList2ListStrided(src, 1, 7, 3);

The result is: [ "b", "c" ]

Probably the most useful application would be:
llList2ListStrided(src, 0, -1, 3);

Which gives the result: [ "a", "b", "c", "d" ]

Q & A:


Q: What's a "stride"?
A: See stride.

Q: How do you get a list of the anything but the first items in the stride? I've tried various combinations of parameters and never got quite what I expected. If I want the whole sub-list I'd expect passing 0 as start would give me a list of the first elements, 1 would give the second elements and so forth, but that's not what happens like an offset into the stride.
A: That is not possible with this function - it can only access the first element in a stride. Perhaps it isn't working as it was originally intended, as the more reasonable way for it to work would indeed be to select elements from the stride based on start.
However, there is actually a workaround for this. To produce a list of all the second elements, just chop the first element off the list with llList2List or llDeleteSubList. This effectively causes llList2ListStrided to offset where it counts the start of the stride from.

So, to get every second element...
llList2ListStrided(llDeleteSubList(src, 0, 0), 0, -1, 2));
and to get every third element...
llList2ListStrided(llDeleteSubList(src, 0, 1), 0, -1, 3));

(For more on removing the first element from the stride, see this forum thread.)

Compare with llList2Float, llList2Integer, llList2Key, llList2List, llList2Rot, llList2String and llList2Vector.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Lists
There are 4 comments on this page. [Display comments/form]