Lambda functions in D

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 9 04:38:37 PDT 2015


On Saturday, 9 May 2015 at 11:20:10 UTC, Dennis Ritchie wrote:
> 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);
> }

dmd says no.


More information about the Digitalmars-d-learn mailing list