Next | Program Repair Shop | 216 |
Problem: Find the minimum of three (or more) values
Programming Style: Examples and Counterexamples contains this example:
if ($x < $y) { if ($x < $z) { $small = $x; } else { $small = $z; } } else { if ($y < $z) { $small = $y; } else { $small = $z; } }
(Translated from the original FORTRAN.)
(In 1974, FORTRAN had no ELSE, so imagine this with six GO TOs instead)
Improved version:
$small = $x; if ($y < $small) { $small = $y } if ($z < $small) { $small = $z }
I don't know what to conclude from this, but it seemed to be worth pointing out
Next | Copyright © 2002 M. J. Dominus |