- or download this
sub bad_average {
my $acc = 0;
...
$acc += $_/@_ for @_;
return $acc;
}
- 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)
- or download this
bad: for (my $x=0; $x<100; $x+=0.1) { ... }
good: for (0..99) { my $x = $_/10; ... }