maxx
The maxx function returns the maximum 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 max function returns the maximum 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.
nMax = ( tbl )
tbl is a general lua table.
nMax is returned as the maximum value found in tbl. If tbl contains no numbers, the huge negative number -1.e308 is returned.
The following script returns the minimum value for an ugly table:
|
-- create a table |
|
-- find the maximum |
|
-- Result: Max = 24 |
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 maximum of the array of 12 elements |
|
-- Result: Min = 12 |
Table and Array Functions, max, minn
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.