Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Finding unique elements in an array

by pelagic (Priest)
on Mar 15, 2005 at 13:28 UTC ( #439619=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Benchmark;
    
    ...
     grep_seen:     15 wallclock secs (14.86 usr +  0.01 sys = 14.87 CPU) 
    +@ 67.23/s (n=1000)
    keys_map_1:     50 wallclock secs (46.78 usr +  0.83 sys = 47.61 CPU) 
    +@ 21.00/s (n=1000)
    keys_map_undef: 43 wallclock secs (42.16 usr +  0.94 sys = 43.09 CPU) 
    +@ 23.21/s (n=1000)
    
  2. or download this
    my @b = map {$a[$_] eq $a[$_ + 1] ? () : $a[$_]} 0..$#a;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-11-17 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (205 votes). Check out past polls.

    Notices?