lua-users home
lua-l archive

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


Is it possible to turn a table into a list, from within lua? I have a lot of functions that take 3 or 4 numbers as parameters, and a lot of data on tables like {1, 2, 3}, so I made a function that turns the table into a list, like this:

function list(t)
        return t[1], t[2], t[3]

to be able to call the functions using list, like 'function(list(t))' listead of 'function(t[1], t[2], t[3])' (yes, this works). Anyway, is it possible to do the same, but with a tables of variable size? I suppose this wouldn't be too hard to do using the C API, but is it possible to do from lua?