Difference between revisions of "ListUnique"
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
== Function: [[list]] ListUnique([[list]] {{LSL Param|lAll }}; == | == Function: [[list]] ListUnique([[list]] {{LSL Param|lAll }}; == | ||
<div style="padding: 0.5em;"> | <div style="padding: 0.5em;"> | ||
Given a list of elements, strips out duplicates in that list. | Given a list of elements, strips out any duplicates in that list, and returns the de-duped list. | ||
<lsl> | <lsl> |
Revision as of 16:41, 12 July 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Function: list ListUnique(list lAll;
Given a list of elements, strips out any duplicates in that list, and returns the de-duped list.
<lsl> list ListUnique( 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 = ListUnique(["A", "A", "B", "C", "C", "B"])
would return the list:
["A", "B", "C"]