title: End of array in variable in julia
body: <p>I would like to slice an array <code>a</code> in Julia in a loop in such a way that it's divided in chunks of <code>n</code> samples. The length of the array <code>nsamples</code> is <em>not</em> a multiple of <code>n</code>, so the last stride would be shorter. </p>
  
  <p>My attempt would be using a ternary operator to check if the size of the stride is greater than the length of the array:</p>
  
  <pre><code>for i in 0:n:nsamples-1
      end_ = i+n &lt; nsamples ? i+n : end
      window = a[i+1:end_]
  end
  </code></pre>
  
  <p>In this way, <code>a[i+1:end_]</code> would resolve to <code>a[i+1:end]</code> if I'm exceeding the size of the array. </p>
  
  <p>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.</p>
  
  <p>In python, I can assign <code>None</code> to <code>end_</code> and this would resolve to <code>a[i+1:None]</code>, which will be the end of the array.</p>
  
  <p>How can I get around this? </p>