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.
nMin = minn( tbl )
tbl is a general lua table.
nMin is returned as the minimum value found in tbl. If tbl contains no numbers, the huge number 1.e308 is returned.
The following script returns the minimum value for an ugly table:
|
-- create a table |
|
-- find the minimum |
|
-- Result: Min = -15 |
The next script returns the minimum value for a 2-dimensional array with no keys or non-numeric values:
|
-- setup a table of rows |
|
-- for each row |
|
-- create a column table |
|
-- for each column |
|
-- assign the value to the column |
|
|
|
-- assign the column table to the row |
|
|
|
-- calculate the minimum of the array of 12 elements |
|
-- Result: Min = 1 |
Table and Array Functions, min, maxx
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.