3 ms·
rolls eyes Index/offset N has semantics of "skip N elements". To get the 1st element, you skip 0 elements. That's it. Combining "skip M" and "skip N" operation
by Joker_vD 5y ago
rolls eyes Index/offset N has semantics of "skip N elements". To get the 1st element, you skip 0 elements. That's it.
Combining "skip M" and "skip N" operations is easy: their total effect is "skip M+N". Combining "get Mth" and "get Nth" operations is, pedantically speaking, meaningless, but is usually understood to mean "imagine Mth was actually the 1st, then get Nth" which in less confusing terms is "skip M-1 elements, then get Nth" which is equivalent to "get (M+N-1)th" operation (Exercise for the reader: convince yourself that the right answer is actually "get (M+N+1)th", then re-convince yourself that the right answer is "get (M+N-1)th").
I personally think always operating in "skip X" is easier than having "get Xth" to sometimes mean "actually, don't get anything, just skip X-1, then...".