Functional Programming with D

qznc qznc at web.de
Sat Apr 13 08:25:38 PDT 2013


Sat, 13 Apr 2013 15:03:51 +0200: Vladimir Panteleev wrote
> On Saturday, 13 April 2013 at 12:29:29 UTC, qznc wrote:
>> While there is no syntactic sugar,
> 
> What about lambdas?
> 
> http://dlang.org/expression.html#Lambda

Oh. I forgot about those. Thanks!

The syntactic sugar seems to be quite diverse, since most of the 
FunctionLiteral is optional. As far as I understand the docs, all the 
following forms are valid?

auto square1 = function int (int x) { return x*x; };
auto square2 = function (int x) { return x*x; };
auto square3 = (int x) { return x*x; };
auto square4 = int (int x) { return x*x; };
auto square5 = (int x) => x*x;
auto square6 = x => x*x;


More information about the Digitalmars-d-announce mailing list