title: Numpy-like slicing in Julia
body: <p>In Python/Numpy I can slice arrays in this form:</p>
  
  <pre><code>arr = np.ones((3,4,5))
  arr[2]
  </code></pre>
  
  <p>and the shape will be maintained:</p>
  
  <pre><code>(arr[2]).shape # prints (4, 5)
  </code></pre>
  
  <p>Which means that, if I want to keep the shape of the array, the following code works for N-dimensional arrays</p>
  
  <pre><code>arr = np.ones((3,4,5,2,2))
  (arr[2]).shape # prints (4, 5, 2, 2)
  </code></pre>
  
  <p>This is great if I want to write functions that work for N-dim arrays preserving their output.</p>
  
  <p>In Julia, however, the same action does not preserve the structure:</p>
  
  <pre><code>arr = ones(3,4,5)
  size(arr[3]) # prints () (0-dimensinoal)
  size(arr[3,:]) # prints (20,)
  </code></pre>
  
  <p>because of partial linear indexing. So if want to keep the original dimensions I need to write <code>arr[3,:,:]</code>, which only works for 3D arrays. If I want a 4D array I would have to use <code>arr[3,:,:,:]</code> and so on. The code isn't general.</p>
  
  <p>Furthermore, when you get to array that are 5 dimensions or more (which is the case I'm working with now) this notation gets extremely cumbersome.</p>
  
  <p>Is there any way I can write code like I do in Python and make it general? I couldn't even think of a nice clean way with reshape, let alone a way that's as clean as Python.</p>