Re:Julia Language Co-Creators Win James H. Wilkinson Prize f...
by phkahler on Wednesday January 23, 2019 @01:00PM
(#18980692)
>> If I say `for x in range(10)` it iterates exactly 10 times
Right and I expect that. The issue I have is that the values do not include 10. It turns out great in Python and Rust where things are 0-indexed, but that does not change the fact that the range construct itself is strange in not including 10.
I'm sure the notion of using mathematical notation where [1..10], (0..10], [1..11), and (0..11) all mean the same thing would drive the language parsing people nuts. Mostly because some of those involve unmatched [) or (]. But that's why we have a computer right?
If I say `for x in range(10)` it iterates exactly 10 times, starting at zero (which is convenient for 0-index lists in python). It would be extremely counter-intuitive if it did [0,10] as it would iterate 11 times. I agree though that it would be much less ambiguous if you could just do `for x in [0..10)`, for example.
Current implementation requires the least amount of "off-by-one" corrections for most tasks, IMO.