is the following code the best way to handle auto-initialization of nested table cells to zero?
function inc3(c,x,y,z) -- inc 3d to zero
c[x] = c[x] or {}
c[x][y] = c[x][y] or {}
c[x][y][z] = c[x][y][z] or 0
c[x][y][z] = c[x][y][z] + 1
end
i ask since this task is the core of my naive bayes classifier. so it must be fast.
notes: the table index names won't be known till runtime, so you can auto-init the data with the right names as a pre-processor.
oh- i've read the automagical table entry (http://lua-users.org/wiki/AutomagicTables) and i cant quite justify to myself that that approach is preferred to the above.