Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
codezero
· 9y ago · 0 comments
I remember being really intrigued when I ran into Fortran programs that used negative array indices. It's pretty handy in a lot of situations.
Comments
[–]
Cyph0n
9y ago
It's commonly used in Python too:
>> last_elem = arr[-1]
>> rev_arr = arr[::-1] # Reverse array
[–]
3JPLW
9y ago
That is something completely different. Where Fortran allows negative indexing is when you initialize your array such the the indices are offset in the same manner as described in the linked article.
[–]
Cyph0n
9y ago
I see. I'm obviously not familiar with Fortran :P