Version 6 of min

Updated 2008-09-19 10:22:13 by FGP

In Tcl 8.5, the expr command has a variadic min() function.

 % expr min(5,1,4,2,3)
 1

 % expr min(5,1.1,-17.345,1e10)
 -17.345

Like all math functions in Tcl 8.5, it is available as a command

 % namespace import ::tcl::mathfunc::min
 % min 5 1 4 2 3
 1

This does not work in releases up to 8.5.4 because max and min are not importable. This should be fixed in subsequent versions.

All arguments to the min must be able to be interpreted as numeric. Otherwise, you get this sort of error:

 % expr min("non-numeric")
 expected floating-point number but got "non-numeric"