1234567891011121314151617181920212223242526272829 |
- 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 pairs(t) then
- for k,v in pairs(t) do
- if type(v) == "table" then
- t2[k] = modpol.util.copy_table(v)
- else
- t2[k] = v
- end
- 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
|