2 ms·
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.
by codeflo 6y ago
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 6y agoC programmers can give you a couple of advises about "correct" modulo on negative numbers.