title: How to filter a Lua array inplace?
body: <p>How to filter a Lua array inplace?</p>
  <p>For example, having an array of  <code>{ 1, 5, 7 }</code> and a function <code>function(elem) return elem &gt; 1 end</code>, the inplace filtering function should change the array to <code>{ 5, 7 }</code>. It is also desired not to break <code>ipairs</code> iteration on the array, so the array should still start with index <code>1</code>.</p>
  <p>By &quot;array&quot; I mean the part of a Lua table that starts with key <code>1</code> and goes through consecutive integer keys until it finds a <code>nil</code>. The same thing you iterate with <code>ipairs</code>.</p>