For instance, one can reduce the two assignments in the outer loop to
$k=$A[$j];
$i=$j-1;
to ($k,$i)=($A[$j],$j-1);
and$A[$i+1]=$A[$i];
$i--;
to ($A[$i+1],$i)=($A[$i],$i-1);
Also the while loop should be gone because it is always the loop require more inspection adn error checking.
This should shorten the loop and reduce the chance of error.
In the case of perl, it also seems to be a good idea to have less $ in the program. Got to think about it.
No comments:
Post a Comment