Difference between revisions of "ListStridedRemove"
Jump to navigation
Jump to search
m (fixed my <lsl> issue :P should have used preview) |
m (<lsl> tag to <source>) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
|p4_type=integer|p4_name=stride | |p4_type=integer|p4_name=stride | ||
|return_type=list | |return_type=list | ||
|return_text= | |return_text= | ||
|func_desc=Removes a | |func_desc=Removes each stride from a list, example a list of 1,2,3,A,1,2,3,A after ListStridedRemove(list,4,0,4); would be 1,2,3,1,2,3 | ||
|func_footnote= created fixed and improved by Madpeter Zond | |||
<source lang="lsl2"> | |||
< | |||
list ListStridedRemove(list src, integer start, integer end, integer stride) | list ListStridedRemove(list src, integer start, integer end, integer stride) | ||
{ | { | ||
if((start < 1) || (stride < 1)) return src; // reverse stride not supported | if((start < 1) || (stride < 1)) return src; // reverse stride not supported | ||
else | else | ||
Line 37: | Line 30: | ||
} | } | ||
} | } | ||
</ | </source> | ||
See also: [[List#Strided_lists|Strided Lists]] | See also: [[List#Strided_lists|Strided Lists]] | ||
|examples= | |examples= | ||
< | <source lang="lsl2">list customers = ListStridedRemove(customers, 0, 0, STRIDELENGTH);</source> | ||
|spec | |spec | ||
|helpers | |helpers | ||
Line 50: | Line 43: | ||
|notes | |notes | ||
|cat1=Examples | |cat1=Examples | ||
|cat2 | |cat2=User-Defined Functions | ||
|cat3 | |cat3 | ||
|cat4 | |cat4 | ||
}} | }} |
Latest revision as of 14:21, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: list ListStridedRemove( list src, integer start, integer end, integer stride );
Removes each stride from a list, example a list of 1,2,3,A,1,2,3,A after ListStridedRemove(list,4,0,4); would be 1,2,3,1,2,3
Returns a list
• list | src | |||
• integer | start | |||
• integer | end | |||
• integer | stride |
created fixed and improved by Madpeter Zond
list ListStridedRemove(list src, integer start, integer end, integer stride)
{
if((start < 1) || (stride < 1)) return src; // reverse stride not supported
else
{
integer loop = start - 1;
integer tricker = 0;
integer maxlen = llGetListLength(src);
if((end == 0) || (end > maxlen)) end = maxlen;
while(loop < end)
{
integer pointid = loop-tricker;
src = llDeleteSubList(src,pointid,pointid);
tricker++;
loop+=stride;
}
return src;
}
}
See also: Strided Lists
Examples
list customers = ListStridedRemove(customers, 0, 0, STRIDELENGTH);