Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One solution to that is have inherently modular array indexing, so that any index is valid.

If A[1] is the first element, then A[0] would be the last; etc



I do appreciate languages that allow -1 for the last index.


That makes it difficult to calculate the distance (length of the slice) between two arbitrary indices though.


Well, that's when you can use the mod operator instead of having to do it when indexing into an array (a much more common operation).


That's a good idea!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: