misc.lua 434 B

12345678910111213141516171819202122
  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.num_pairs
  12. -- @param t table with pairs
  13. -- Returns the number of elements in a pairs table
  14. function modpol.util.num_pairs(t)
  15. local i = 0
  16. for k,v in pairs(t) do
  17. i = i + 1
  18. end
  19. return i
  20. end