Definition:
|
object x1 = min(object x2, object x3)
-- or --
object x1 = min(sequence s1)
|
Description:
|
Returns the smallest of x2 and x3, or the smallest element in sequence s1.
Atoms are considered to be less than sequences. Sequences are compared
"alphabetically" (case sensitive, ie 'Z'<'a') starting with the first
element until a difference is found.
|
Example 1:
|
x = min(7,5) -- x is 5
y = min({9,7,5}) -- y is 5
|
Example 2:
|
x = min("one","two") -- x is "one"
y = min({"one","two","three","four"}) -- y is "four"
|
See Also:
|
equal,
compare,
max,
relational operators,
sequence operations
|
Technicalia
|
min(s1) is an alias for minsq(s1); the compiler automatically substitutes
the function being called when only one parameter is passed. However should
you code minsq(x,y) then expect a compilation error. Both routines are
declared in builtins\pmaths.e (an auto-include). Some extra care must be taken
with routine_id("min"), as obviously no equivalent mapping occurs for the one or two
parameter cases.
The OpenEuphoria version of min() only accepts a single argument and behaves as
minsq(flatten(s1)), whereas the Phix version is not recursive. Unlike the
OpenEuphoria version, min(<atom>) generates a runtime error, as does min({}).
This function is only compatible with OpenEuphoria when passed a single argument that
is a non-empty and non-nested sequence of atoms. Unlike several other functions there
is no separate sq_min function. Should you (for some strange reason) want
min({"one","two","three"}) to yield 'e', or min({}) to yield +inf, then may I politely
suggest that you write your own version of this routine.
|