Files
modpol/modpol_core/util/misc.lua

29 lines
592 B
Lua

--- Miscellaneous functions
-- @module modpol.util.misc
modpol.util = {}
--- Returns a copy of the table inputted
-- @function modpol.util.copy_table
-- @param t table to copy
-- @return copy of table
function modpol.util.copy_table(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
--- Returns the number of elements in a pairs table
-- @function modpol.util.num_pairs
-- @param t pairs table
-- @return number of elements in 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