title: passing a function as an argument in python
body: <p>Suppose I want to calculate the following <code>f(f(...f(x)..)</code> .<br>
  Basically many times function of itself.<br>
  Currently I am doing the following to achieve this result (and to return all the intermediate steps):</p>
  
  <pre><code>def iterator(function, x, n=4):
      x = float(x)
      arr = []
      for i in range(n + 1):
          arr.append(x)
          x = function(x)
  
      return arr
  
  def funcM(x):
      return x / 4 + 12
  </code></pre>
  
  <p>and then I am passing my function <code>funcM</code> as an argument:<br>
  <code>print iterator(funcM, 100, 5)</code>.</p>
  
  <p>There is nothing wrong with this approach, and calculations are correct.</p>
  
  <p>But is there a way to do the same without defining function <code>funcM</code> ?<br>
  May be passing lambda function as an argument to iterator function (Sorry if it does not make sense, I do not really know what lambda functions are).</p>