Douglas King on Nostr: npub1gfdrr…x7gg6 Indexing starts at zero on programming for the same reason house ...
npub1gfdrrw9629qxwvwaa3vwnvzhtaqu2c5m9wf6vcwjnmdnhs7hl4jsux7gg6 (npub1gfd…7gg6)
Indexing starts at zero on programming for the same reason house numbers in the city start at the zero of their block. It's an address offset.
For example the address 2400 Walnut St in Philadelphia is the building on the corner of 24th and Walnut.
It's zero houses from the corner.
In a list or array in programming, the first element is zero items from the start.
This is the metaphor I use when teaching programming.
Indexing starts at zero on programming for the same reason house numbers in the city start at the zero of their block. It's an address offset.
For example the address 2400 Walnut St in Philadelphia is the building on the corner of 24th and Walnut.
It's zero houses from the corner.
In a list or array in programming, the first element is zero items from the start.
This is the metaphor I use when teaching programming.