Lambda functions in D

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 9 04:20:09 PDT 2015


Hi,
Can lambda functions or delegates in D to call themselves?
Can I write something like this:

-----
import std.stdio;

void main() {

	auto fact = function (int x) => x * { if (x) fact(x - 1); };

	assert(fact(10) == 3628800);
}


More information about the Digitalmars-d-learn mailing list