lua - Popping the first element off an array -
i have array x
in lua. set head = x[1]
, rest =
rest of array, rest[1] = x[2]
, rest[2] = x[3]
, etc.
how can this?
(note: don't care if original array gets mutated. in javascript head = x.shift()
, x
contain remaining elements.)
"pop" bit of misnomer, implies cheap operation, , removing first element of table requires relocating rest of contents--hence name "shift" in javascript , other languages.
Comments
Post a Comment