3 ms·
I think you're still conflating two different concepts, but this is mostly natural at this point since I assume you program in languages that use 0-based indexi
by VWWHFSfQ 2y ago
I think you're still conflating two different concepts, but this is mostly natural at this point since I assume you program in languages that use 0-based indexing. 1-based indexing focuses on the conceptual sequence rather than the underlying implementation details. Even your matrix flattening example is conflating concepts, although that's "normal" at this point. 0-based indexing certainly lends itself nicely to interval arithmetic, I agree.
> What index does the flattened `mt` start at?
I'm not sure if I missed a point you were getting at with this? Lua array table indexes start at 1.
- Gibbon1 2y agoMy first boss who started in the late 60's said 1 based indexing exists because the early programmers with mathematics training thought ordinary people are too stupid to get zero based indexing.
- IshKebab 2y agoYeah I think that's the only plausible reason. Quite patronising but I think it probably came from an honest "make programming more accessible to non-programmers" place. They just forgot that the rest of programming exists... You see that in books and papers and tutorials a lot. They'll explain some basic concepts nicely and then realise that they can't really explain ELI5 calculus and skip straight into Laplace transforms. I once read a highly technical manual for a SystemVerilog simulator that began by explaining what double-clicking was. No joke. That's basically 1-based indexing.
- IshKebab 2y ago> I'm not sure if I missed a point you were getting at with this? Lua array table indexes start at 1. The code example is mt = {} -- create the matrix for i=1,N do for j=1,M do mt[i*M + j] = 0 end end What index do I use to access the first element in mt? It isn't 1! If this was written using 0-based indices then the answer would be zero.