lua-users home
lua-l archive

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

On Thu, 5 Sep 2013 08:52:47 +0200
David Demelier <> wrote:

> For me, I personally miss more something like table.find (which never
> existed). A kind of function like that would be great :-), there's
> also table.sort so table.find could be a great improvement.
> Cheers,

You could easily write your own table.find that iterates through all
items til it finds a value that matches the argument. But it would be
slow with big tables.

More practical might be to have an index table whose keys are the value
or value part in question, and whose values are the key of the original
table. Then you write your table.find something like


You'd probably put an add metamethod on orgtable to write the correct
entry to indextable.

I'm not a Comp Sci expert, but I'd imagine this would continue to have
fast lookups, on a one by one basis, even if you had 10K items in the



Steve Litt                *
Troubleshooting Training  *  Human Performance