package BasicMath;

use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(&min &max &med);

sub min {
  my $cur_min = shift; 
  foreach (@_) {
     $cur_min = $_ if ( $_ < $cur_min ); 
  }
  return $cur_min;  
}

sub max {
  my $cur_max = shift;
  foreach (@_) {
     $cur_max = $_ if ( $_ > $cur_max );
  }
  return $cur_max;
}

sub med {
  my @nms = sort {$a <=> $b} @_;
  my $count = scalar @nms;
  return undef unless $count;
  my $mid = $count/2;  
  ($count % 2)
        ? $nms[$mid] : ($nms[$mid] + $nms[$mid-1]) / 2.0;
}

1;




