in reply to Re: minimum, maximum and average of a list of numbers at the same time
in thread minimum, maximum and average of a list of numbers at the same time
And with List::Util::reduce()...
use List::Util qw/ reduce /; sub min_max_avg { $res= reduce { my $r= ref $a ? $a : [($a) x 3]; if ($b < $r->[0]) { $r->[0]= $b; } elsif ($b > $r->[1]) { $r->[1]= $b; } $r->[2]+=$b; $r } @_; return @$res[0,1], $res->[2] / @_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: minimum, maximum and average of a list of numbers at the same time
by Limbic~Region (Chancellor) on Nov 10, 2005 at 13:45 UTC | |
|
Re^3: minimum, maximum and average of a list of numbers at the same time
by codeacrobat (Chaplain) on Nov 12, 2005 at 09:58 UTC | |
by demerphq (Chancellor) on Nov 12, 2005 at 11:02 UTC |