Anonymous recursion: Difference between revisions

Content added Content deleted
(→‎{{header|Bracmat}}: Replaced the program with a much shorter version, changed the text.)
Line 158: Line 158:
</lang>
</lang>


{{works with|C++11}}
The upcoming C++0x standard includes lambda functions which simplifies this.
<lang cpp>#include <functional>
<lang cpp>#include <functional>
using namespace std;
using namespace std;
Line 167: Line 167:
throw "Invalid argument";
throw "Invalid argument";
function<double(double)> actual_fib = [&](double n)->double
function<double(double)> actual_fib = [&](double n)
{
{
if(n < 2) return n;
if(n < 2) return n;