sumn
The sumn function sums all numeric values in a general lua table that may contain a multi-dimensional array or a mixture of numbers, strings, named keys, and sub-tables. Only numeric values found in the table are used in the calculation. The related sum function sums 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.
value = sumn( tbl )
tbl is a general lua table.
value is the sum of numeric elements in the table.
The following script sums all members of a 1-dimensional array.
|
-- create 10000 random numbers |
|
-- sum all members of the array |
The next script sums the values in a complex, ugly table:
|
|
|
-- sum the numeric elements |
|
-- result: Sum = 24 |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.