title: How to sum a table of numbers in Lua?
body: <p>Does Lua have a builtin <code>sum()</code> function? I can't seem to find one, and I've looked almost everywhere in the documentation. Maybe <code>table.sum()</code>, or something of the like, to follow the current conventions. But since I couldn't find it, I had to implement it:</p>
  
  <pre><code>function sum(t)
      local sum = 0
      for k,v in pairs(t) do
          sum = sum + v
      end
  
      return sum
  end
  </code></pre>
  
  <p>It seems kind of funny to have to implement something this simple, though. Does a builtin function exist, or no?</p>