title: Get all subarrays from an array using a single loop
body: <p>I was wondering if there is an algorithm / pattern where someone could get/parse all subarrays of a given  array
  using for example a simple loop.</p>
  
  <p>For example: for the array  <code>myArray{0,1,2,3}</code>    I need</p>
  
  <pre><code>myArray(0,0)myArray(0,1),myArray(0,2),myArray(0,3)
  myArray(1,1)myArray(1,2),myArray(1,3)
  myArray(2,2)myArray(2,3),
  myArray(3,3)
  </code></pre>
  
  <p><strong>I do not want</strong> to use something like </p>
  
  <pre><code>for (i = 0; i &lt; myArray.length; i++) {
      for (j = i; j &lt; myArray.length; j++)
      {
  
      }
  }
  </code></pre>
  
  <p>since I want my algorithm to be faster. </p>