Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Find unique elements in an array

by etcshadow (Priest)
on Apr 05, 2004 at 02:30 UTC ( #342554=note: print w/replies, xml ) Need Help??


in reply to Find unique elements in an array

Not that it is any different in the manner that it works, but I've always preferred:
my @uniquelist = keys %{{map {$_=>1} @nonuniquelist}};
An anonomous hash makes it much more compact.
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: Find unique elements in an array
by BrowserUk (Pope) on Apr 05, 2004 at 03:09 UTC

    It's compact, but far and away the slowest method.

    However, you can combine elements of yours with tilly's performance trick and get something that is both fairly compact and almost as quick.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-02-17 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (70 votes). Check out past polls.

    Notices?