e
given transformation with each element of this sequence.</p>
<p>Use this method to receive a single-level collection when your
transformation produces a sequence or collection for each element.</p>
<p>In this example, note the difference in the result of using <code>map</code> and
<code>flatMap</code> with a transformation that returns an array.</p>
<pre><code class="language-swift">let numbers = [1, 2, 3, 4]

let mapped = numbers.map { Array(repeating: $0, count: $0) }
// [[1], [2, 2], [3, 3, 3], [4, 4, 