"initialize my $sum = 0;"
An interesting variation, that is probably premature optimization in simple cases, is to:
sub average { my $sum = shift @_; ...;
For algorithms such as moving averages or integrators initializing the accumulator with the first sample value can be essential to avoiding large glitches at the start of the result data.
In reply to Re^3: Passing Variables
by GrandFather
in thread Passing Variables
by catfish1116
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |