ListUnique

From Second Life Wiki
Revision as of 16:40, 12 July 2008 by Chaz Longstaff (talk | contribs) (New page: {{LSL Header}} __NOTOC__ <div id="box"> == Function: list ListUniq(list {{LSL Param|lAll }}; == <div style="padding: 0.5em;"> Given a list of elements, strips out duplicates in tha...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function: list ListUniq(list lAll;

Given a list of elements, strips out duplicates in that list.

<lsl> list ListUniq( list lAll ) {

   integer i;
   list lFiltered = llList2List(lAll, 0, 0);
   integer iAll = llGetListLength( lAll );
   for (i = 1; i < iAll; i++) {
       if ( llListFindList(lFiltered, llList2List(lAll, i, i) ) == -1 ) {
           lFiltered += llList2List(lAll, i, i);
       }
   }
   return lFiltered;

}

</lsl>


Example:

list mylist = ListUniq(["A", "A", "B", "C", "C", "B"])

would return the list:

["A", "B", "C"]