your point about the range-computing subroutine being called only once when using a Perl-style foreach loop (as compared to the "equivalent" C-style loop) is very interesting.
I sometimes wondered, in similar cases, whether I should pre-compute the range limits in order to sort of cache them before entering the for loop, but never actually cared to check, now I know that, in such cases, Perl is actually doing the value caching for you. Good to know. Thank you, Athanasius.
In reply to Re^2: Smoothsort
by Laurent_R
in thread Smoothsort
by QuillMeantTen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |