Help for this page

Select Code to Download


  1. or download this
    sub bad_average {
       my $acc = 0;
    ...
       $acc += $_/@_ for @_;
       return $acc;
    }
    
  2. or download this
    bad:     if ($x == $y)
    abs tol: if (abs($x - $y) < $abs_tol)
    rel tol: if (abs($x - $y) < abs($x) * $rel_tol)
    
  3. or download this
    bad:  for (my $x=0; $x<100; $x+=0.1) { ... }
    good: for (0..99) { my $x = $_/10; ... }