lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jan 14, 2011 at 02:30, Drake Wilson <drake@begriffli.ch> wrote:
> Quoth Emmanuel Oga <emmanueloga@gmail.com>, on 2011-01-14 01:12:40 -0300:
>> Is there any other more elegant way?
>
> There's not much that's "elegant" in the sense of "easy using the Lua
> table library" or such, that I can see.  If I were coding it all the
> way down, I'd do something like this:
> [snip]

I've submitted a variant of your code to LuaSnippets[1]. My function
removes a element according to the predicated, instead of keeping it.
The function is optimized to avoid unnecessary table assignments by
finding contiguous slots "marked" as to-be-kept.

--rb

[1] http://snippets.luacode.org/snippets/Filter_a_table_in-place_2_120