misc.lua 406 B

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