Difference between revisions of "ListStridedRemove"

From Second Life Wiki
Jump to: navigation, search
m
m (<lsl> tag to <source>)
 
Line 10: Line 10:
 
|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_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
 
|func_footnote= created fixed and improved by Madpeter Zond
<lsl>
+
<source lang="lsl2">
 
list ListStridedRemove(list src, integer start, integer end, integer stride)
 
list ListStridedRemove(list src, integer start, integer end, integer stride)
 
{
 
{
Line 30: Line 30:
 
     }
 
     }
 
}
 
}
</lsl>
+
</source>
  
 
See also: [[List#Strided_lists|Strided Lists]]
 
See also: [[List#Strided_lists|Strided Lists]]
 
|examples=
 
|examples=
<lsl>list customers = ListStridedRemove(customers, 0, 0, STRIDELENGTH);</lsl>
+
<source lang="lsl2">list customers = ListStridedRemove(customers, 0, 0, STRIDELENGTH);</source>
 
|spec
 
|spec
 
|helpers
 
|helpers

Latest revision as of 15:21, 22 January 2015

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);