in reply to Re: Re: Sorting characters within a string
in thread Sorting characters within a string
Were I autogenerating, my approach might be as follows (untested):
Note that the nested map will be much slower than you think if you are pre 5.6.1. Personally I would be inclined to use the Orcish (for "Or Cache") maneuver for this:{ my @c = qw(A T C G N); my @strings = @c; foreach (1..5) { foreach (@strings) { $sorted_str{$string} = join '', sort, split //; } @strings = map { my $string = $_; map $string.$_, @c; } @strings; } }
$bases = $sorted{$bases} ||= join '', sort, split //, $bases;
|
|---|