[Dlang-internal] [OT] What do you think about declaring functions with lambda syntax?
IGotD-
nise at nise.com
Sat Dec 5 00:55:23 UTC 2020
On Friday, 4 December 2020 at 11:12:23 UTC, ddcovery wrote:
> Example:
>
> import
> std.stdio,
> std.algorithm,
> std.array,
> std.conv
> ;
>
> ulong factorial(ulong n) =>
> n>1 ? factorial(n-1)*n : 1
> ;
>
> T[] sorted(T)(T[] xs) =>
> xs.length == 0 ? [] :
> xs[1..$].filter!(x=> x < xs[0]).array.sorted ~
> xs[0..1] ~
> xs[1..$].filter!(x=> x >= xs[0]).array.sorted
> ;
>
> void main() =>
> [5,6,7,2,3].sorted.map!(i=>i.to!ulong.factorial).writeln
> ;
It is really ugly and doesn't help readability. It looks like
another language.
More information about the Dlang-internal
mailing list