in reply to Is it possible to make reference to substrings and sort them?
With a bit of index arithmetic and a manual compare function you would get
my $ntext = length $text; my $bwt2 = join('', map{substr($text, ($_ - 1), 1)} sort{ my $j = -1; my $diff = 0; while( $j++<$ntext ) { $diff = substr( $text, ($j+$a) % $ntext, 1 ) cmp substr( $text +, ($j+$b) % $ntext, 1 ); last if $diff; } return $diff; } 0..$ntext-1 ); print "$text: $bwt2\n";
Whether or not this is faster, I do not know, but it avoids building all the cyclic rotations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is it possible to make reference to substrings and sort them?
by hdb (Monsignor) on Mar 22, 2015 at 13:20 UTC | |
by Anonymous Monk on Mar 22, 2015 at 19:17 UTC | |
|
Re^2: Is it possible to make reference to substrings and sort them?
by spooknick (Novice) on Mar 22, 2015 at 21:09 UTC |