title: yield python add previous function result
body: <p>I want to write a function that would use yield , but every time the value of the field to send to the function would be the previous result:</p>
  
  <p>for instance, if the call to </p>
  
  <p>f(5) returns 10, the next call would f(10). if the result of f(10) returns 18 the next call will be f(18)</p>
  
  <p>How can I do it?
  I wrote this code:</p>
  
  <pre><code>def my_function(f,init_value):
    yield init_value
    while True:
       yield f(init_value)
  </code></pre>
  
  <p>But it always returns the call to f(init_value) and not as I would expect.</p>