Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
romwell
on Aug 24, 2021
|
parent
|
context
|
favorite
| on:
The Nelua Programming Language
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
mst
on Aug 24, 2021
|
next
[–]
I do appreciate languages that allow -1 for the last index.
layer8
on Aug 24, 2021
|
parent
|
next
[–]
That makes it difficult to calculate the distance (length of the slice) between two arbitrary indices though.
romwell
on Aug 25, 2021
|
root
|
parent
|
next
[–]
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).
0-_-0
on Aug 25, 2021
|
prev
[–]
That's a good idea!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
If A[1] is the first element, then A[0] would be the last; etc