[Wellington-pm] At the buzzer

pfCd?Y*_Qbdb6 at perform.shyuser.com pfCd?Y*_Qbdb6 at perform.shyuser.com
Fri Aug 20 11:35:45 PDT 2010


Grant submitted the best solution for an abbreviated moving 
average.
Any monger like to comment why these expressions produce the 
same result?

use List::Util qw(sum);

   $product1 = average_5d(@split_line);

   sub average_5d {
       my $sum = sum map { $_->[7] } @_[1..5];
       return $sum / 5;
   }


#Next the expression was bumped a day [2..6] to produced a
#comparison between $product1 and $product1A .


use List::Util qw(sum);

   $product1A = average_5d(@split_line);

   sub average_5d {
       my $sum = sum map { $_->[7] } @_[2..6];
       return $sum / 5;
   }


More information about the Wellington-pm mailing list