title: Pad an array with 0's swift
body: <p>I am attempting to pad an an array with zeros but cannot find a succinct way to do this in swift.
  If I have array x = [1,2,3 ; 4,5,6 ; 7,8,9]
  in matlab I could use the command</p>
  
  <pre><code>y = [zeros(1,3+2);zeros(3,1),x,zeros(3,1);zeros(1,3+2)]
  </code></pre>
  
  <p>giving the desired output array of [0,0,0,0,0; 0,1,2,3,0 ; 0,4,5,6,0 ; 0,7,8,9,0 ; 0,0,0,0,0]</p>
  
  <p>However so far in a swift playground I have only been able to refer to each element individually to correctly form the new array. </p>
  
  <p>The methods I have tried so far using x as the input and y as the output, the first similar to matlab,</p>
  
  <pre><code>var x = [[1,2,3,],[4,5,6],[7,8,9]]
  
  var y = [[0,0,0,0,0],[0,x[0],0],[0,x[1],0],[0,x[2],0],[0,0,0,0,0]]
  </code></pre>
  
  <p>The second being a loop</p>
  
  <pre><code>for i in 0 ..&lt; x.count + 1 {
    if i == 0 || i == x.count - 1 {
      y[i] = [0,0,0,0,0]
    }
    else{
      y[i] = [0, x[i-1] ,0]
    }
  }
  </code></pre>
  
  <p>Rather than looking like a standard array in the Xcode playground preview this is the output given.</p>
  
  <pre><code>[[0, 0, 0, 0, 0], [0, […], 0], [0, 0, 0, 0, 0], [0, […], 0], [0, 0, 0, 0, 0]]
  </code></pre>
  
  <p>which also prints to the console very strangely, using the code</p>
  
  <pre><code>for i in 0 ..&lt; y.count {
      print("\(y[i])")
  }
  </code></pre>
  
  <p>the output is</p>
  
  <pre><code>(
      0,
      0,
      0,
      0,
      0
  )
  (
      0,
          (
          1,
          2,
          3
      ),
      0
  )
  (
      0,
      0,
      0,
      0,
      0
  )
  (
      0,
          (
          7,
          8,
          9
      ),
      0
  )
  (
      0,
      0,
      0,
      0,
      0
  )
  </code></pre>
  
  <p>as opposed to the expected</p>
  
  <pre><code>[0, 0, 0, 0, 0]
  [0, 1, 2, 3, 0]
  [0, 4, 5, 6, 0]
  [0, 7, 8, 9, 0]
  [0, 0, 0, 0, 0]
  </code></pre>
  
  <p>What is the best way to do this?</p>