Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: how to speed up dupe checking of arrays

by FunkyMonk (Chancellor)
on Jul 31, 2007 at 10:23 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://629788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found