Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
codeflo
on Jan 20, 2021
|
parent
|
context
|
favorite
| on:
Again on 0-based vs. 1-based indexing
I think the most mathematically natural way to interpret negative indices is to threat them as numbers modulo list length. Then 0 = length, and -1 = length - 1.
bvrmn
on Jan 20, 2021
[–]
C programmers can give you a couple of advises about "correct" modulo on negative numbers.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: