Convince me that Lua's 1 based array indexing isn't moronic and wrong.
It's All Fucked Shirt $22.14 |
Tip Your Landlord Shirt $21.68 |
It's All Fucked Shirt $22.14 |
Convince me that Lua's 1 based array indexing isn't moronic and wrong.
It's All Fucked Shirt $22.14 |
Tip Your Landlord Shirt $21.68 |
It's All Fucked Shirt $22.14 |
Humans count starting from 1. Also your name is moronic.
>addressing and counting are the same thing
Why are nocoders so fricking moronic?
>want to access the 1st (first) element on an array
>"i-it's 0, o-okay? it j-just is, don't ask w-why."
you can't get to 1 apple unless you first start with 0 apples
that's not true
then it's not an index, it's an offset. the mental gymnastics cniles will perform to justify their errors...
if it was moronic why do they call it 1 based instead of 1 cringe?
0-indexed is just because of how pointer arithmetic works in arrays. Lua is explicitly a high-level programming language often used for scripting. there is no reason why its indexing needs to reflect array arithmetic. 1-indexed is far more traditional in mathematics
I find that in practice doing arithmetic with indices is more ergonomic and relies on fewer edge-cases when using 0-based indexing.
it's a really high level language, so it's reasonable to start counting from a more natural number
i never had an issue mentally accounting for it when i would write garry’s mod shit. always seemed like a non-issue. the lack of a robust standard library and any modules written for it being out of date / unmaintained is a very real problem though. still a great language regardless.
It's not worth $20/m
20 dollars per meter? of what?
the moon. buying land on the moon isn't worth it. it's a white elephant. you'll lose everything in transportation costs
When you draw a 2-axis graph do you label the origin 1,1?
Yes.
Don't lump Lua-tan with your stupid spam threads.
0 does not exist. its a psyop. not a natural number, does not occur anywhere in the real world.
glass has 20 water
sun evaporates water
glass has 0 water
glass has 1/infinity water actually (Newton, not zero)
anon is right, 0 and negative numbers were invented by the oven people to fool you into getting in debt
Cero is definitely a natural number. You can lack resources, materials, objects in general in nature that your brain is aware that exist. Negative numbers are a israeli psyop 100% though.
glass has no (false) water
1 is more intuitive and would have saved devs from "of by one" confusion problems that sometimes happen when working in arrays but in practical terms all the languages under the sun use 0 so just make it 0 for consistency at this point
It's too late now[0]
We won't be able to do
if index:
because index can be an index and falsey
We will be forced to subtract 1 from every index in our head
Forever
You start at the first element. For every further element, you skip one element. To get the first element, you skip no elements, which why it's index 0.
You can use based 0 indexing in Lua, though. It's just that everyone will hate you for it. Also you can't use the array constructor syntax.
lua was made by brazillians
they've apologized with elixir, which atones for their sins, but never forget
The choice of 1 or 0 indexing is arbitrary, 1-indexing is more natural for non-programmers, and this "debate" is peak bikeshedding.
No it isn't. 1 based indexes break a lot of indexing arithmetic. As a very simple example lets say you want to find the nth slice of a 3 slices with 30 values array. If you index with 0 you can have
>X * 30
or maybe
>(X-1) * 30
and this will give you the start of the row, but if you have 1 based indexes strides just become kinda confusing, and you always have to add a 1. There is a fundamental difference between offsets (which is what arrays are), and counting things. There is literally no reason to use 1 as the first index, especially because everyone is used to doing arithmetic with offset based logic.
intervals start from zero
items (labels of those intervals) start from 1