in reply to Get average value of array of numbers
use List::Util qw(sum); sub mean { return sum(@_)/@_; }
sum returns the summation of all the elements in the array. Dividing by @_ (which in scalar context gives the number of elements) returns the average.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get average value of array of numbers
by AnomalousMonk (Archbishop) on Oct 15, 2009 at 19:27 UTC | |
|
Re^2: Get average value of array of numbers
by swampyankee (Parson) on Oct 15, 2009 at 19:49 UTC | |
|
Re^2: Get average value of array of numbers
by Anonymous Monk on Oct 15, 2009 at 14:10 UTC |