Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: how to speed up dupe checking of arrays

by FunkyMonk (Canon)
on Jul 31, 2007 at 10:23 UTC ( #629788=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @rows = qw/ 1 2 3 4 1 2 /; # 1 & 2 are dups
    my @non_dupe_rows = do { my %seen;grep !$seen{$_}++, @rows };
    print "@non_dupe_rows\n";
    
  2. or download this
    1 2 3 4
    
  3. or download this
    my @rows = qw/ 1 2 3 4 1 2 /; # 1 & 2 are dups
    my @non_dupe_rows = do {
    ...
        grep $seen{$_} == 1, keys %seen
    };
    print "@non_dupe_rows\n";
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://629788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-07-26 02:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls