30 lines
572 B
Lua
30 lines
572 B
Lua
modpol.util = {}
|
|
|
|
--- @function modpol.copy_table
|
|
-- @param t table
|
|
-- Returns a copy of the table inputted
|
|
function modpol.util.copy_table(t)
|
|
local t2 = {}
|
|
if ipairs(t) then
|
|
for i,v in ipairs(t) do
|
|
t2[i] = v
|
|
end
|
|
elseif pairs(t) then
|
|
for k,v in pairs(t) do
|
|
t2[k] = v
|
|
end
|
|
end
|
|
return t2
|
|
end
|
|
|
|
--- @function modpol.num_pairs
|
|
-- @param t table with pairs
|
|
-- Returns the number of elements in a pairs table
|
|
function modpol.util.num_pairs(t)
|
|
local i = 0
|
|
for k,v in pairs(t) do
|
|
i = i + 1
|
|
end
|
|
return i
|
|
end
|