title: Can lambda functions be recursive?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2067988/recursive-lambda-functions-in-c0x">Recursive lambda functions in c++0x</a>  </p>
  </blockquote>
  
  
  
  <p>Here is a plain old recursive function:</p>
  
  <pre><code>int fak(int n)
  {
      return (n &lt;= 1) ? 1 : n * fak(n - 1);
  }
  </code></pre>
  
  <p>How would I write such a recursive function as a lambda function?</p>
  
  <pre><code>[](int n) { return (n &lt;= 1) ? 1 : n * operator()(n - 1); }
  // error: operator() not defined
  
  [](int n) { return (n &lt;= 1) ? 1 : n * (*this)(n - 1); }
  // error: this wasn't captured for this lambda function
  </code></pre>
  
  <p>Is there any expression that denotes the current lambda so it can call itself recursively?</p>