FFRANK has asked for the wisdom of the Perl Monks concerning the following question:
This is not very realistic for large AoA's, it is not efficient, and there is certainly a linear solution. A solution could look like (?) :#!/usr/bin/perl -w use strict; use Algorithm::Loops qw(NestedLoops); my @symbol = ( [ 'a', 'b', 'c' ], [ 'a', 'b', 'c' ], [ 'a', 'b', 'c' ], [ 'c', 'd', 'e' ], ); my @all; my $iter = NestedLoops(\@symbol); my @list; while (@list = $iter->()) { my @sortedList = sort @list; my $listString = join ('',@sortedList); push @all, $listString; } my @uniq = keys %{{ map { $_ => 1 } @all }}; my @sortedUniq = sort (@uniq); foreach my $sortedUniq (@sortedUniq) { print $sortedUniq,"\n"; }
Could it be a good option to add to nestedLoops ? Thanks for comments & hints, very best regards.for my $symbolRow (0..$#symbol) { for my $symbolCol (0..$#{$matrix[$symbolRow]}) { # If, for elements 1..$#{$matrix[$symbolRow]} #the element (symbol) already exists in a preceeding line #remove from current line. # Then proceed with nested loops.
|
---|