When describing slicing, the notebook incorrectly states that
if no value is passed to end, it is assumed that
end = length of array - 1
It should be end = length of array
From the docs:
If j is not given it defaults to n
When describing slicing, the notebook incorrectly states that
if no value is passed to end, it is assumed that
end = length of array - 1
It should be end = length of array
From the docs:
If j is not given it defaults to n
But counting of elements in an array starts from 0 not 1, the nth element wont exist.
The documentation reported by Izak_van_Zyl_Marais on slicing says:
“The basic slice syntax is i:j:k where i is the starting index, j is the stopping index, and k is the step”
and
“Assume n is the number of elements in the dimension being sliced … If j is not given it defaults to n for k > 0 and -n-1 for k < 0.”
where, as already mentioned, n is the number of elements (without subtracting 1).
In fact, since the slice function stops to (j-1) index, if j is not given it should be j = n = length of array, in order to slice till the (n-1)-th position in the array, where there is the last element.