Skip to content

Commit 8c57309

Browse files
authored
Merge pull request #317 from astrofrog/zero-indexing
Clarify sentence related to counting from zero
2 parents 06de7a4 + e72e40c commit 8c57309

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

_episodes/01-numpy.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ but `data[0, 0]` might.
337337
Programming languages like Fortran and MATLAB start counting at 1,
338338
because that's what human beings have done for thousands of years.
339339
Languages in the C family (including C++, Java, Perl, and Python) count from 0
340-
because that's more convenient when indices are computed rather than constant
341-
(see [Mike Hoye's blog post](http://exple.tive.org/blarg/2013/10/22/citation-needed/)
342-
for historical details).
340+
because it represents an offset from the first value in the array (the second
341+
value is offset by one index from the first value). This is closer to the way
342+
that computers represent arrays (if you are interested in the historical
343+
reasons behind counting indices from zero, you can read
344+
[Mike Hoye's blog post](http://exple.tive.org/blarg/2013/10/22/citation-needed/)).
343345
As a result,
344346
if we have an M×N array in Python,
345347
its indices go from 0 to M-1 on the first axis

0 commit comments

Comments
 (0)