-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.lua
More file actions
34 lines (27 loc) · 817 Bytes
/
table.lua
File metadata and controls
34 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Table functions implemented into Lua
local table = table or {}
function table.move(a1, f, e, t, a2)
-- Moves elements [f, e] from array a1 into a2 starting at index t
-- table.move implementation
-- @param table a1 from which to draw elements from range
-- @param number f starting index for range
-- @param number e ending index for range
-- @param number t starting index to move elements from a1 within [f, e]
-- @param table a2 the second table to move these elements to
-- @default a2 = a1
-- @returns a2
a2 = a2 or a1
t = t + e
for i = e, f, -1 do
t = t - 1
a2[t] = a1[i]
end
return a2
end
function table.pack(...)
-- Returns a new table with parameters stored into an array, with field "n" being the total number of parameters
local t = {...}
t.n = #t
return t
end
return table