2 min - minimum, or minimum of defined minima
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.
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:
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.
26 If x_i has the null value, it is ignored. Thus, sum(a, , b, , c)
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).
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.
43 ; print min(2), min(5, 3, 7, 2, 9), min(3.2, -0.5, 8.7, -1.2, 2.5)
46 ; print min(list(3,5), 7, list(6, list(7,8), 2))
49 ; print min("one", "two", "three", "four")
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}
60 ; define point_min(a) = a.x
65 The number of arguments is not to exceed 1024.
68 NUMBER *qmin(NUMBER *x1, NUMBER *x2)
73 ## Copyright (C) 1999-2006 Landon Curt Noll
75 ## Calc is open software; you can redistribute it and/or modify it under
76 ## the terms of the version 2.1 of the GNU Lesser General Public License
77 ## as published by the Free Software Foundation.
79 ## Calc is distributed in the hope that it will be useful, but WITHOUT
80 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
81 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
82 ## Public License for more details.
84 ## A copy of version 2.1 of the GNU Lesser General Public License is
85 ## distributed with calc under the filename COPYING-LGPL. You should have
86 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
87 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
89 ## @(#) $Revision: 30.1 $
90 ## @(#) $Id: min,v 30.1 2007/03/16 11:10:42 chongo Exp $
91 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/min,v $
93 ## Under source code control: 1995/10/05 04:52:27
94 ## File existed as early as: 1995
96 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
97 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/