title: Howto recursively call a function with a function as a parameter
body: <p>From the Question <a href="https://stackoverflow.com/questions/213267/how-do-i-pass-a-function-as-a-parameter-to-in-elisp">How do I pass a function as a parameter to in elisp?</a> I know how to pass a function as a parameter to a function. <strong>But</strong> <em>we need to go deeper...</em>   </p>
  
  <p>Lame movie quotes aside, I want to have a function, which takes a function as a parameter and is able to call itself [again passing the function which it took as parameter]. Consider this snippet:  </p>
  
  <pre class="lang-lisp prettyprint-override"><code>(defun dummy ()
    (message "Dummy"))
  
  (defun func1 (func)
    (funcall func))
  
  (defun func2 (func arg)
    (message "arg = %s" arg)
    (funcall func)
    (func2 'func (- arg 1)))
  </code></pre>
  
  <p>Calling <code>(func1 'dummy)</code> yields the expected output: </p>
  
  <pre class="lang-lisp prettyprint-override"><code>Dummy    
  "Dummy"
  </code></pre>
  
  <p>Calling <code>(func2 'dummy 4)</code> results in an error message:  </p>
  
  <pre class="lang-lisp prettyprint-override"><code>arg = 4
  Dummy
  arg = 3
  funcall: Symbol's function definition is void: func
  </code></pre>
  
  <p>I had expected four calls to dummy, yet the second iteration of <code>func2</code> seems to have lost its knowledge of the function passed to the first iteration (and passed on from there). Any help is much appreciated!</p>