Lambda returning a lambda?

Alex sascha.orlov at gmail.com
Thu Feb 1 13:45:52 UTC 2018


On Thursday, 1 February 2018 at 11:51:11 UTC, aliak wrote:
> Is there a way to do this:
>
> import std.stdio;
>
> void main()
> {
>     alias f = (a) => (b) => a * b;
>     f(2)(3).writeln;
> }
>
> Error now is: Error: template lambda has no type
>
> Cheers

This works:

void main()
{
	auto f = (size_t x) => (size_t y) => x * y;
	f(2)(3).writeln;
}

and this:

void main()
{
	alias f(T) = (T x) => (T y) => x * y;
	f!size_t(2)(3).writeln;
}


More information about the Digitalmars-d-learn mailing list