Something like this:
template fib(ulong n)
{
static if( n < 2 )
const fib = n;
else
const fib = fib!(n-1) + fib!(n-2);
if( n < 2)
return n;
return fib(n-1) + fib(n-2);
}It doesn't work of course, as I am in a template and trying to "return" something.
CTFE? Is that "compile time function evaluation"? If yes, it's really slow...
If I try: static x = fib(40); // fib is a normal function it takes forever and makes my pc run really slowly.
