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))
  table.insert (a, arg)
  return unpack (a)

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


Attachment: pgpR4PM7xsN9O.pgp
Description: PGP signature