On Monday, 30 December 2013 at 11:23:39 UTC, Ilya Yaroshenko wrote:
Hello!

Is there any ability to lambda function call itself?

Is it correct feature for D?

Best Regards,
Ilya

Well it's possible to do this (sort of).

//You could for instance define the Factorial function like this.

int delegate(int) f;
f = (int x) => x > 0 ? f(x - 1) * x : 1;

It's not very pretty and offers little compared to just make it a normal function.
void f(int x) { return x > 0 ? f(x - 1) * x : 1; }

Reply via email to