minn


The minn function returns the minimum value of a general lua table that may contain non-numeric values, named keys, and sub-tables. Only numeric values found in the table are used in the calculation. The related min function returns the minimum value of a 1-dimensional array, CImage, or list of numbers. Since an array is a specific type of table that contains only numbers or sub-tables, this function can also be used for arrays.

Syntax

nMin = minn( tbl )

bullet.gif    tbl is a general lua table.

bullet.gif    nMin is returned as the minimum value found in tbl. If tbl contains no numbers, the huge number 1.e308 is returned.

Examples

The following script returns the minimum value for an ugly table:

t = { { 1, "c", a=-12, dar={17,"v"} }, {-15, 24, 3, 5} }

-- create a table

v = minn( t )

-- find the minimum

Printf("Min = %lg\n", v )

-- Result: Min = -15

  

The next script returns the minimum value for a 2-dimensional array with no keys or non-numeric values:

row = {}

-- setup a table of rows

for j = 1, 4 do

-- for each row

  col = {}

-- create a column table

  for i = 1,3 do

-- for each column

    col[i] = i*j

-- assign the value to the column

  end

 

  row[j] = col

-- assign the column table to the row

end

 

v = minn( row )

-- calculate the minimum of the array of 12 elements

Printf("Min = %lg\n", v )

-- Result: Min = 1

Related Topics

Table and Array Functions, min, maxx


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.