misc.lua 388 B

12345678910111213141516171819
  1. --- @function modpol.copy_table
  2. -- Returns a copy of the table inputted
  3. function modpol.util.copy_table(t)
  4. local t2 = {}
  5. for k,v in pairs(t) do
  6. t2[k] = v
  7. end
  8. return t2
  9. end
  10. --- @function modpol.copy_table
  11. -- Returns the number of elements in a pairs table
  12. function modpol.util.num_pairs(t)
  13. local i = 0
  14. for k,v in pairs(t) do
  15. i = i + 1
  16. end
  17. return i
  18. end