Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Unique rows in Array of array

by johngg (Abbot)
on Sep 03, 2012 at 16:55 UTC ( #991476=note: print w/ replies, xml ) Need Help??


in reply to Unique rows in Array of array

choroba gives you a solution for the problem as you present it but, more generally, if you have arrays with longer rows the number of conditions inside the grep becomes unwieldy. A nested grep solution can overcome this.

$ perl -E ' > @arr = ( > [ 1, 3, 6 ], > [ 8, 8, 8 ], > [ 3, 9, 0 ], > [ 1, 4, 5, 3, 6, 9, 4, 2 ], > [ 2, 2, 2, 2, 2, 2, 2 ], > ); > > @neq = > grep { > $zero = $_->[ 0 ]; > grep { $zero != $_ } @$_[ 1 .. $#{ $_ } ] > } @arr; > > say qq{@$_} for @neq;' 1 3 6 3 9 0 1 4 5 3 6 9 4 2

I hope this is of interest.

Cheers,

JohnGG


Comment on Re: Unique rows in Array of array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2014-07-25 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (172 votes), past polls