xHarbour Reference Documentation > Function Reference |
Returns the smallerr value of two Numerics or Dates.
Min( <nNum1> , <nNum2> ) --> nSmallerNumber Min( <dDate1>, <dDate2> ) --> dSMallerDate
The function returns the smaller value of the two arguments.
The function compares two numeric or two Date values and returns the smaller value of both. Min() is used to normalize values against a limit. The inverse function is Max().
See also: | Max() |
Category: | Numeric functions , Date and time |
Source: | rtl\minmax.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example compares elements of two arrays of different // length. The limit for the loop counter is determined with // function Min(). Array elements containing same values are // collected in a result array. PROCEDURE Main LOCAL aArray1 := {"A", "B", "C", "D" } LOCAL aArray2 := {"D", "B", "C" } LOCAL aResult := {} LOCAL i, imax imax := Min( Len( aArray1 ), Len( aArray2 ) ) FOR i:=1 TO imax IF aArray1[i] == aArray2[i] AAdd( aResult, aArray1[i] ) ENDIF NEXT ? ValToPrg( aResult ) // result: { "B", "C" } RETURN
http://www.xHarbour.com