Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Fast Way to Return Unique Array of Array

by GrandFather (Saint)
on Sep 05, 2005 at 04:09 UTC ( [id://489136]=note: print w/replies, xml ) Need Help??


in reply to Fast Way to Return Unique Array of Array

This may be what you are trying to achieve, though it's not very pretty:

use strict; use warnings; use List::Compare::Functional qw(is_LequivalentR); use Data::Dumper; my @AoA = (['a','b','c'], ['a','b','c'], ['a','b','d'], ['a','b','d']); my @uAoA; skip: for my $ia (0..(@AoA-1)){ for my $ir (0..(@uAoA-1)){ next skip if is_LequivalentR ([\@{$AoA[$ia]}, \@{$uAoA[$ir]}]); } push @uAoA, [@{$AoA[$ia]}]; } print Dumper \@uAoA;

Outputs:

$VAR1 = [ [ 'a', 'b', 'c' ], [ 'a', 'b', 'd' ] ];

Perl is Huffman encoded by design.

Log In?
Username:
Password:

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

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

    No recent polls found