lua-users home
lua-l archive

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


On Thursday 23 February 2006 12:27 pm, Javier Guerra wrote:
> On Thursday 23 February 2006 11:50 am, Chris wrote:
> > That made me think, a substring style unpack could be useful.
>
> this seems to work:
(snip C code)
>

lua (5.0) equivalent:

function split (n, ...)
  local a = {}
  for i = 1, n do
    table.insert (a, table.remove (arg, 1))
  end
  table.insert (a, arg)
  return unpack (a)
end

now... would there be any significant performance difference?

-- 
Javier

Attachment: pgp5ob2MU_NpM.pgp
Description: PGP signature