focus expression text field at startup -> version 1.2
[LeanCalc.git] / help / min
1 NAME
2     min - minimum, or minimum of defined minima
3
4 SYNOPSIS
5     min(x_1, x_2, ...)
6
7 TYPES
8     x_1, x_2, ...       any
9
10     return              any
11
12 DESCRIPTION
13     If an argument x_i is a list with elements e_1, e_2, ..., e_n, it
14     is treated as if x_i were replaced by e_1, e_2, ..., e_n; this may
15     continue recurively if any of the e_j is a list.
16
17     If an argument x_i is an object of type xx, then x_i is replaced by
18     xx_min(x_i) if the function xx_min() has been defined.  If the
19     type xx has been defined by:
20
21                 obj xx = {x, y, z},
22
23     an appropriate definition of xx_min(a) is sometimes min(a.x, a.y, a.z).
24     min(a) then returns the minimum of the elements of a.
25
26     If x_i has the null value, it is ignored.  Thus, sum(a, , b, , c)
27
28     If x_i has the null value, it is ignored.  Thus, min(a, , b, , c)
29     will return the same as min(a, b, c).
30
31     Assuming the above replacements, and that the x_1, x_2, ..., are
32     of sufficently simple ordered types (e.g. real numbers or strings),
33     or, if some are objects, the relevant xx_rel(a,b) has been defined
34     and returns a real-number value for any comparison that has to be made,
35     min(x_1, x_2, ...) returns the value determined by min(x_1) = x_1,
36     and succesively for later arguments, by the use of the equivalent of
37     min(a,b) = (a < b) ? a : b.  If the ordering determined by < is total,
38     min(x_1, ...) will be the minimum value among the arguments.  For a
39     preorder relation it may be one of several minimal values.  For other
40     relations, it may be difficult to predict the result.
41
42 EXAMPLE
43     > print min(2), min(5, 3, 7, 2, 9), min(3.2, -0.5, 8.7, -1.2, 2.5)
44     2 2 -1.2
45
46     > print min(list(3,5), 7, list(6, list(7,8), 2))
47     2
48
49     > print min("one", "two", "three", "four")
50     four
51
52     > obj point {x, y}
53     > define point_rel(a,b) = sgn(a.x - b.x)
54     > obj point A = {1, 5}
55     > obj point B = {1, 4}
56     > obj point C = {3, 3}
57     > print min(A, B, C)
58     obj point {1, 5}
59
60     > define point_min(a) = a.x
61     > print min(A, B, C)
62     1
63
64 LIMITS
65     The number of arguments is not to exceed 100.
66
67 LINK LIBRARY
68     NUMBER *qmin(NUMBER *x1, NUMBER *x2)
69
70 SEE ALSO
71     max, obj
72