Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 scrutinizing the Monastery: (17)
As of 2015-07-02 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls