I would like to slice an array a in Julia in a loop in such a way that it's divided in chunks of n samples. The length of the array nsamples is not a multiple of n, so the last stride would be shorter.
My attempt would be using a ternary operator to check if the size of the stride is greater than the length of the array:
for i in 0:n:nsamples-1
end_ = i+n < nsamples ? i+n : end
window = a[i+1:end_]
end
In this way, a[i+1:end_] would resolve to a[i+1:end] if I'm exceeding the size of the array.
However, the use of the keyword "end" in line 2 is not acceptable (it's also the keyword for "end of control statement" in julia.
In python, I can assign None to end_ and this would resolve to a[i+1:None], which will be the end of the array.
How can I get around this?