lua-users home
lua-l archive

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


> I'm unaware of any efficient way to iterate backwards through a sequence in Lua.

We're running in circles. A sequence in Lua has no holes and # returns
the number of elements in a sequence. So, to iterate backwards through a
sequence in Lua, just do

	for i=#t,1,-1 do print(i,t[i]) end

ipairs and # are meant to be used on sequences and they work without
surprises on sequences. They are not useful for things that are not
sequences and may surprise some people in this case but they are
breaking the contract.

Can we move on now?