title: Execute Function until Predicate is Satisfied
body: <p>I'm trying to write a function, <code>doAndRepeatUntil</code> that calls a function <code>f</code> until a predicate/condition <code>pred</code> is true.</p>
  
  <p>In the following code, I would expect <code>@sum</code> to start at 0, and then print <code>10, 20, ..., 90, 100</code> and then terminate.</p>
  
  <pre><code>doAndRepeatUntil = (f, pred) -&gt;
    console.log @sum
    f() until pred()
  
  @sum = 0
  
  f = -&gt;
    @sum += 10
  
  pred = -&gt;
    @sum &gt;= 100
  
  console.log f() # NaN
  
  doAndRepeatUntil(f, pred) # infinite loop
  </code></pre>
  
  <p>However, I'm seeing <code>f()</code> print out <code>NaN</code>. And <code>doAndRepeatUntil(f,pred)</code> spins in an infinite loop.</p>