lua-users home
lua-l archive

Removing holes from a list

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


For example:
list=table.pack(1,2,3,nil,4,5,nil,nil,6,7)
I have several ugly methods that work, e.g. operate
with two indices inside a while loop until one reaches
list.n, make a new table containing the non-nil entries
and assign it to `list`.
Does anyone have a method that deserves to be
called elegant?

AltStyle によって変換されたページ (->オリジナル) /