title: Best way to handle while loop style program in Scala
body: <p>I have a simple program written in C++. It generates random numbers, and stop when the sum of those numbers equal or greater than 100. The code looks like:</p>
  
  <pre><code>vector&lt;int&gt; container;
  while(container.sum() &lt;100)
  {
      int new_number = rand()%10 + 1 ;// generate a number in range 1 to 10
      container.push_back(new_number); // add new number to the container
  
  }
  </code></pre>
  
  <p>What is the best way to handle the task in Scala? (without using while loop?) </p>
  
  <p>It seems that FoldLeft or FoldRight function doesn't have ability to break at a condition?</p>