Canon Camera Hackers Manual page 120

Camera hackers manual berthold daum
Table of Contents

Advertisement

table.insert (table, pos, value)
Inserts value at the specified position into the table, shifting existing elements at and
behind that location one position towards the end of the table. If pos is omitted, the
value is appended at the end of the table.
m = table.maxn (table)
Returns the maximum positive index of the table. If no positive index exists, 0 is
returned.
e = table.remove (table [, pos])
Removes the element at the specified position from the table and returns it. If pos is
not supplied, the very last element in the table is removed.
table.sort (table, comp)
Sorts the elements in the table. Optionally, a function can be supplied in comp defin-
ing the sort order. The function receives two table elements as parameters and must
return true if the first element is considered smaller than the second element.
Example:
table.sort(table,
function(a,b)
return a > b
end
)
will sort the table in the opposite order because it returns true when the second
parameter is smaller than the first.
Mathematical functions
Because the CHDK implementation of Lua only supports integer numbers,
mathematical functions in the Lua mathematical library, such as sin() or
log(), would make no sense. The mathematical library therefore boils
down to:
math.max()
Returns the maximum of its arguments
math.min()
Returns the minimum of its arguments
math.pow(x,y)
Raises the first parameter to the power of the second
parameter and returns the result
or
x^y
math.random(x,y)
Generates random numbers between x and y. If x is omitted,
a lower limit of 0 is assumed.
math.randomseed()
Sets a start value for the pseudo random generator. A typical
way to initialize the random generator is randomseed(os.
time()).
111
5.4 Lua primer

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents