5.4 Lua primer
111
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)
or
x^y
Raises the first parameter to the power of the second
parameter and returns the result
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())
.
Содержание Camera
Страница 1: ......
Страница 2: ...The Canon Camera Hackers Manual ...
Страница 3: ......
Страница 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Страница 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Страница 25: ...16 CH APTER 3 ...
Страница 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Страница 213: ...204 CH APTER 6 ...
Страница 253: ...244 AP PENDIX ...