perlquestion
emilbarton
<p>I asked indirectly a question in [id://923065] that I'd like to extend here to a wider audience: </p>
<p>Is there a means to obtain the translation seed "n0123.." permutationally?</p>
<p>The translation seed allows to shift any permutational string to the right by one sign. What I mean by <b>permutationally</b> is that you can obtain your result with the help of the function perm() primarily. For example the natural suite "0123..n" can be obtained permutationally by repeating y = perm(x,x) and then y1 = perm(y,x) enough times with y1,y2,etc. for any permutation x. In [id://923065] I think that with some more efforts, the function comp() could be reduced to a particular composition of calls to perm().</p>
<p>I know it's more a math question than a Perl one but I found that it was not a bad idea to ask for the wisdom of Perl monks - who are used to deal with generic problems of this kind after all. Getting the translation seed permutationally should make a system of permutational functions more efficient.</p>
<code>
sub perm {
my ($target,$agent) = @_;
my @targ = split //,$target;
my @perm = split //,$agent;
my $res;
for (my $i = 0; $i < (@perm); $i++){ $res .= $perm[$targ[$i]] }
return $res;
}
</code>
<p>Comment:</p>
<p>By "permutation" we understand any permutation of the distinct elements pertaining to the natural - or well ordered - suite "01..n". The function perm() above accepts two permutations in the same base n+1 < 11. For this function, "012", "3102", "7465023198", are valid permutations when "013", "3112" or "7465023198A" are not.</p>