Neverworld Grid

You are not logged in. Would you like to login or register?



6/10/2019 6:02 pm  #1


A UDF to remove duplicates from a list

// Given a list of elements, strips out any duplicates in that list, and returns the de-duped list.
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;
}

// A *possibly* faster replacement

list StripDupes(list DupedList)
{
    integer pos;
    list Element; list NoDupes;
    while (llGetListLength(DupedList) != 0)
    {
        Element = llList2List(DupedList, 0, 0);
        NoDupes += Element;
        pos = llListFindList(DupedList, Element);
        while ( pos != -1)
        {
            DupedList = llDeleteSubList(DupedList, pos, pos);
            pos = llListFindList(DupedList, Element);
        }
    }
    return NoDupes;
}

default
{
    state_entry()
    {
        
    }
}

 

Board footera

 

Powered by Boardhost. Create a Free Forum