title: How to iterate over whole array when I need i, j, k?
body: <p>Given <code>A</code> is a multi-dimensional array, can I collapse iteration through every element into one <code>for</code> statement if I need <code>i,j,k,etc.</code>? In other words, I am looking for a more compact version of the following:</p>
  <pre><code>for k in 1:size(A,3)
    for j in 1:size(A,2)
      for i in 1:size(A,1)
        # Do something with A[i+1,j,k], A[i,j+1,k], A[i,j,k+1], etc.
      end
    end
  end
  </code></pre>
  <p>I think the solution is with <code>axes</code> or <code>CartesianIndices</code>, but I can't get the syntax right. Failed attempts:</p>
  <pre><code>julia&gt; for (i,j,k) in axes(A)
           println(i)
         end
  1
  1
  1
  
  julia&gt; for (i,j,k) in CartesianIndices(A)
             println(i)
         end
  ERROR: iteration is deliberately unsupported for CartesianIndex. Use `I` rather than `I...`, or use `Tuple(I)...`
  </code></pre>
  <p>It would be great if in addition to a solution which defines <code>i,j,k</code>, you could also provide a solution that works regardless of the number of dimensions in <code>A</code>.</p>