Re: Duplicates List from Sequence

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here's an easy function to remove dupe elements from a sequence, which I
knew for a long time and have kept it to myself until now:

function del_dupes( sequence in )
    sequence out
    out = {}
    for i = 1 to length( in ) do
        if not find( in[i], out ) then
            out = append( out, in[i] )
        end if
    end for
    return out
end function

To list out ONLY duplicates, it merely requires some modification:

function list_dupes( sequence in )
    sequence out, check
    out = {}
    check = {}
    for i = 1 to length( in ) do
        check = append( check, in[in] )
        if find( in[i], check ) then
            out = append( out, in[i] )
        end if
    end for
    return out
end function

Be warned that list_dupes() was cooked up without being tested. Hope this
helps!

Lionel
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu