lua-users home
lua-l archive

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

How smart looks this Egor ... :).

... but if I am not completely stupid, this "table.move..." line is
not quite correct, it should better be:
table.move(list, pos + count, #list, pos)


And can you give me a hint, by which miraculous trick this bizarre
return construction should return the removed elements?

(generally I think in an interpreter language as Lua, it is always a
very good idea, to support any user in avoiding for loops for "common
tasks". I think this are only some small amount of C lines more to
program this, but Luiz of course is completely reasonable to ask for
some C code proposal for this... then much more easy to discuss "C
code weight" against "Lua code advantage".

Am Sa., 10. Sept. 2022 um 23:09 Uhr schrieb Egor Skriptunoff
>    return
>       (
>          function (...)
>             table.move(list, pos + count, #list + count, pos)
>             return ...
>          end
>       )
>       (
>          table.unpack(list, pos, pos + count - 1)
>       )
> end