listStridedRemove

From Second Life Wiki
Jump to navigation Jump to search

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