Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
codeflo
· 5y ago · 0 comments
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.
Comments
[–]
bvrmn
5y ago
C programmers can give you a couple of advises about "correct" modulo on negative numbers.