1. Duplicates List from Sequence
Who has the fastest duplicate finder?
sequence a = { a, b, c, d, e, a, b, c, f }
dupeList = duplicates(a)
dupeList = { a, b, c }
Maybe it should return positions in the sequence, such as
dupeList = { {1,6}, {2,7}, {3,8} }
Anybody have thoughts on this?
Thanks!
< |<
2. Re: Duplicates List from Sequence
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