Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How do I find unique Array in Array of Arrays?

by bart (Canon)
on Dec 18, 2007 at 13:23 UTC ( [id://657671]=note: print w/replies, xml ) Need Help??


in reply to How do I find unique Array in Array of Arrays?

There's a likely cheaper solution to stringify an array of strings (no nested arrays) than using Data::Dumper: if you first quotemeta every string and then join by any \W character (except '\'), then you can uniquely recognize any combination of characters in the arrays, because the join string will not have a prepending backslash, and every \W character in the data will.

In addition, I'm using fewer extra data structures than in the other proposed solutions.

my %seen; my @aoa = grep { not $seen{join " ", map quotemeta, @$_}++ } @AoA;

Log In?
Username:
Password:

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

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

    No recent polls found