in reply to Re^2: porting C code to Perl -- solved
in thread porting C code to Perl
not sure if it's better or worse, but I'd change that toforeach my $i( reverse 1..$len){ my $x = 10 * $a[$i-1] + $q * $i; $a[$i-1] = $x % (2 * $i - 1); $q = int($x / (2 * $i - 1)); }
not for efficiency, but for (perhaps) easier understandingforeach my $i( reverse 0 .. $len-1){ my $x = 10 * $a[$i] + $q * ($i+1); my $divisor = 2 * $i + 1; $a[$i] = $x % $divisor; $q = int($x / $divisor); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: porting C code to Perl -- solved
by Discipulus (Canon) on Oct 23, 2017 at 19:59 UTC |