Re:Edsger Dijkstra's note on starting array indices at 0 (pd...
by Zakharov on Tuesday June 21, 2011 @08:46PM
(#2681088)
I find it much more natural to represent "{1,2,3,4,5}" as "1..5" or "range(1,5)", not "1..6" or "range(1,6)".
[ Parent
| on HN ]
Re:Edsger Dijkstra's note on starting array indices at 0 (pd...
by sltkr on Tuesday June 21, 2011 @11:34PM
(#2681593)
Dijkstra's point is that you should start counting at 0, so if you want to generate the first five ordinals, you would write [0:5) which yields {0,1,2,3,4} as expected.
Re:Edsger Dijkstra's note on starting array indices at 0 (pd...
by chalst on Wednesday June 22, 2011 @03:09AM
(#2682090)
In formal methods its common to have a special notation 0 -> N which is 0 .. N-1. That way, a sequence of length M+N consists of a sequence with indices 0 -> M and a sequence with indices M -> M+N.