It does look to be the most efficient as you suspected.
The really fastest version -- which is only applicable if you no longer need the original array and can modify it in place, which is often the case in my work -- is:
my $i = 0; $x[ $i ] -= $x[ ++$i ] while $i < $#x; --$#x;
But the saving comes from not allocating more memory; and all the algorithms would benefit from that.
In reply to Re^6: Abusing Map (Corrected second code block)
by BrowserUk
in thread Abusing Map
by writch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |