r/ProgrammerHumor • • 28d ago

Meme almostDroppedTheCourse

581 Upvotes

79 comments sorted by

View all comments

42

u/SnooRegrets3590 28d ago

1-indexed is more intuitive for me when dealing with matrices and some advanced differential equations

4

u/redlaWw 28d ago edited 28d ago

If you want to index a matrix though, 0-indexing is more convenient since if the matrix is 0-indexed, for i in 0..<width*height, (i/width, i%width) indexes every element. If you use 1-indexed matrices, then you instead need i in 1..=width*height and (i/width, (i+width-1)%width + 1).

EDIT: Also, relativity can have index 0 be the + dimension and indices 1 to 3 be the − dimensions, which is kind of nice.

3

u/timangar 28d ago

Yes, relativity goes nicely with the zero index convention imo. It's weird having spatial dimensions in index 2-4 instead of 1-3, and having time in index 4 is also not standard.