lua-users home
lua-l archive

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

hello, PA <>.

On Fri, 3 Aug 2007 13:06:24 +0200
PA <> wrote:

> How does one generalize that to insert a value anywhere in a varargs?
rewrite table.insert in Lua, so it will use xxx.n, not #n. something

local function NewInsert (tbl, position, value)
  if position <= tbl.n then
    for f = tbl.n, position, -1 do tbl[f+1] = tbl[f]; end;
  tbl[position] = value;
  return tbl;