identifying the duplicate when removing duplicates from any array



Hello,

The following removes duplicates from my array, however I cannot figure
out how to get Perl to also output the duplicate offender itself, since
I want to know "which" was the actual duplicate it removed on the
output... knowing what below is the duplicate is simple by looking at
the array (t1), but imagine a huge array, and you want to know "which"
were the dups after processing, what would I need to add to the code
below to output the actual duplicate being t1 ? Any tips are
appreciated :

@in = ("t1", "t2", "t1", "t3");
# Sort First, then Dedup
@in = sort @in;
# Start Dedup routine into @out array
print " IN ", $#in;
$prev = "not equal to $in[0]";
@out = grep($_ ne $prev && ($prev = $_, 1), @in);
print " OUT ", $#out;

Thank you !
Jack

.



Relevant Pages

  • Re: Repost (Comparing two ranges)
    ... I was on the right track assuming a countif type function instead of ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: How to choose Random rows??
    ... whole numbers could return duplicate values if the range between Min and ... This function will return an array of random Long Integers between the values of Minimum and Maximum....It is possible that there will be duplicated values in the result array. ... A common requirement is the selection of some number of elements at random and without repetition ... ClassicVB Users Regroup! ...
    (microsoft.public.excel.programming)
  • RE: Speed up Array Transfer to Dictionary
    ... of comparisons every time you have a known duplicate. ... array with themselves. ... array in the first place as a dictionary cannot have duplicate keys. ... dupe = dupe + 1 ...
    (microsoft.public.excel.programming)
  • Re: How to return cell reference
    ... Well.....these array formulas seem to work fine with duplicate ... First instance of "John" in A1:M10 ... With Dupe Cells: C3 and A6 ...
    (microsoft.public.excel)
  • Re: Repost (Comparing two ranges)
    ... range A2:A6 to drive data validation dropdown boxes in the range B9:D11. ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ...
    (microsoft.public.excel.worksheet.functions)