title: Sequence of Number, through Iteration
body: <p>I have the following vector of indices</p>
  <pre><code>V_ind = cumsum(c(10,9,8,7,6,5,4,3,2,1))
  [1] 10 19 27 34 40 45 49 52 54 55
  </code></pre>
  <p>And I created the following FOR LOOP</p>
  <pre><code>k=1
  
  for(ind in V_ind){
   if(ind&lt;=10){
    print(&quot;ok&quot;)
   }else{
    print(c(V_ind[1:k]))
    k = k + 1
   }
  
  }
  </code></pre>
  <p>Which gives as a result</p>
  <pre><code>[1] &quot;ok&quot;
  [1] 10
  [1] 10 19
  [1] 10 19 27
  [1] 10 19 27 34
  [1] 10 19 27 34 40
  [1] 10 19 27 34 40 45
  [1] 10 19 27 34 40 45 49
  [1] 10 19 27 34 40 45 49 52
  [1] 10 19 27 34 40 45 49 52 54
  </code></pre>
  <p>However, what I try to acheive is the following result</p>
  <pre><code>[1] &quot;ok&quot;
  [1] 10
  [1]  9 10 19
  [1]  8  9 10 18 19 27
  [1]  7  8  9 10 17 18 19 26 27 34
  [1]  6  7  8  9 10 16 17 18 19 25 26 27 33 34 40
  [1]  5  6  7  8  9 10 15 16 17 18 19 24 25 26 27 32 33 34 39 40 45
  [1]  4  5  6  7  8  9 10 14 15 16 17 18 19 23 24 25 26 27 31 32 33 34 38 39 40 44 45 49
  [1]  3  4  5  6  7  8  9 10 13 14 15 16 17 18 19 22 23 24 25 26 27 30 31 32 33 34 37 38 39 40 43 44 45 48 49 52
  [1]  2  3  4  5  6  7  8  9 10 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 29 30 31 32 33 34 36 37 38 39 40 42 43 44 45 47 48 49 51 52 54
  </code></pre>
  <p>This result goes as follows:</p>
  <ol>
  <li><p>In the first iteration, we just print OK</p>
  </li>
  <li><p>In the second iteration, we extract the first element of the vector <code>V_ind</code>,</p>
  </li>
  <li><p>In the third iteration, we extract the first and second element of the vector <code>V_ind</code> together with the first element of the vector <code>V_ind</code> minus 1 that is the number <code>9</code>.</p>
  </li>
  <li><p>In the fourth iteration, we extract the first, second and third element of the vector <code>V_ind</code>, together with the first element minus 1, i.e. <code>9</code>, first element minus 2, i.e <code>8</code>, and second element minus 1,i.e.<code>18</code>.</p>
  </li>
  <li><p>In the fifth iteration, we extract the first, second, third and fourth element of the vector <code>V_ind</code> together with the first element minus 1, 2, 3 respectively, i.e <code>7,8,9</code>, also the second element minus 1 and 2, i.e <code>17,18</code>, and the third element minus 1, i.e <code>26</code>.</p>
  </li>
  </ol>
  <p>And this procedure goes until the end of the FOR LOOP. Is this even possible to be done in R, in a generic way?</p>