4 ms·
When I started Julia I was annoyed by it. Then I realized that 90% of my mental gymnastics with indices got simplified. Explaining indexing to newbies is now i
by Certhas 8y ago
When I started Julia I was annoyed by it.
Then I realized that 90% of my mental gymnastics with indices got simplified. Explaining indexing to newbies is now immediate where before it took a slide, several examples, and a clever picture. Slicing is also more natural:
"1:3 picks out index 1, 2 and 3, which are the first, second and third element of the array."
Instead of the python version of
"0:4 picks out index 0, 1 and 2, which are the first, second and third element of the array."
- petre 8y agoLess off by one errors for one.
- saghm 8y ago> "0:4 picks out index 0, 1 and 2, which are the first, second and third element of the array." I don't think that's right? It should pick out four things, not three. Of course, you could argue that getting that wrong proves your point! I personally still prefer 0-indexing, but I definitely agree with you that having an exclusive upper bound is confusing.
- Certhas 8y agoYou're right of course. Not intentional. 0:3 picks out index 0, 1, 2. So 1:3 picks out the second and third element, which are indexed by 1 and 2 respectively. My guess is that what one prefers probably depends entirely on the data structures one works with most....
- shele 8y agoI like how you got it wrong, proving your point.