lua-users home
lua-l archive

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


>> On 31-Mar-18 14:24, Doug Gale wrote:
>> I hate one-based indexing. It adds a ton of confusion when embedding lua into a native programming language project, and tarnishes what I'd consider to be a fantastically good language otherwise.

My last post responded to the wrong comment ... Sorry

You can use lua table with arbitrary base by using the hash part:

local T = {[0]=0, 1}   -- 0-based critical table

Above is actual code of my primepi.lua (line 20)
Doing it in 1-based array is messy and slower.

https://github.com/achan001/PrimePi/blob/master/primepi.lua