Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?

by dragonchild (Archbishop)
on Nov 30, 2007 at 04:23 UTC ( [id://654035]=note: print w/replies, xml ) Need Help??


in reply to Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?

List::MoreUtils uniq() preserves order.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?

Replies are listed 'Best First'.
Re^2: Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?
by mreece (Friar) on Nov 30, 2007 at 04:35 UTC
    curiously, (the pure-perl version of) List::MoreUtils::uniq uses
    map { $h{$_}++ == 0 ? $_ : () } @_;
    rather than
    grep { !$h{$_}++ } @_;
    i wonder, a simple preference or are there interesting micro-optimizations in the map verison?
      I have no idea. If I were to guess, I would say that it probably has to do with a bug report that was received for 5.6.0 on some random OS we've never heard of. Lack of comments make this unclear.

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found