3 ms·
How does that fall within the definition of "base index"? that's just array position referencing. You can't even create an array/list in python w/o a hard 0 re
by irjustin 6y ago
How does that fall within the definition of "base index"? that's just array position referencing.
You can't even create an array/list in python w/o a hard 0 reference.
- klyrs 6y agoFirst, it's a "joke", second, nobody is going to force you to use non-negative indices. Sure, you can use a base index of zero and read left to right... but you can use a base index of -1 and read right to left and live a full (if lonely) life without considering the passé alternatives. More precisely, I'm defining the "base" to be the right hand side of the array and operating on the reversed list -- it's just a change of variables. Python supports -1 based indexing, but does not support 1 based indexing. You could easily define a language which only provides the -1 based indexing but does not support 0-based. Let me demonstrate: void *malloc_r(int size, int count) { void *m = malloc(size, count+1; m[count] = count; return m+count; } void free_r(void *m) { free(m - m[0]); } Memory allocated through malloc_r is right-aligned and you should only use negative indices. Best not touch m[0]!