Files
calc/help/max
2017-05-21 15:38:36 -07:00

72 lines
2.1 KiB
Plaintext

NAME
max - maximum, or maximum of defined maxima
SYNOPSIS
max(x_1, x_2, ...)
TYPES
x_1, x_2, ... any
return any
DESCRIPTION
If an argument x_i is a list with elements e_1, e_2, ..., e_n, it
is treated as if x_i were replaced by e_1, e_2, ..., e_n; this may
continue recurively if any of the e_j is a list.
If an argument x_i is an object of type xx, then x_i is replaced by
xx_max(x_i) if the function xx_max() has been defined. If the
type xx has been defined by:
obj xx = {x, y, z},
an appropriate definition of xx_max(a) is sometimes max(a.x, a.y, a.z).
max(a) then returns the maximum of the elements of a.
If x_i has the null value, it is ignored. Thus, sum(a, , b, , c)
If x_i has the null value, it is ignored. Thus, max(a, , b, , c)
will return the same as max(a, b, c).
Assuming the above replacements, and that the x_1, x_2, ..., are
of sufficently simple ordered types (e.g. real numbers or strings),
or, if some are objects, the relevant xx_rel(a,b) has been defined
and returns a real-number value for any comparison that has to be made,
max(x_1, x_2, ...) returns the value determined by max(x_1) = x_1,
and succesively for later arguments, by the use of the equivalent of
max(a,b) = (a < b) ? b : a. If the ordering determined by < is total,
max(x_1, ...) will be the maximum value among the arguments. For a
preorder relation it may be one of several maximal values. For
other relations, it may be difficult to predict the result.
EXAMPLE
> print max(2), max(5, 3, 7, 2, 9), max(3.2, -0.5, 8.7, -1.2, 2.5)
2 9 8.7
> print max(list(3,5), 7, list(6, list(7,8), 2))
8
> print max("one", "two", "three", "four")
two
> obj point {x, y}
> define point_rel(a,b) = sgn(a.x - b.x)
> obj point A = {1, 5}
> obj point B = {1, 4}
> obj point C = {3, 3}
> print max(A, B, C)
obj point {3, 3}
> define point_max(a) = a.x
> print max(A, B, C)
3
LIMITS
The number of arguments is not to exceed 100.
LIBRARY
NUMBER *qmax(NUMBER *x1, NUMBER *x2)
SEE ALSO
max, obj