Lambda Tuple with Map Reduce

Stanislav Blinov stanislav.blinov at gmail.com
Wed Apr 20 08:41:17 UTC 2022


On Wednesday, 20 April 2022 at 08:37:09 UTC, Salih Dincer wrote:
> On Wednesday, 20 April 2022 at 08:04:42 UTC, Salih Dincer wrote:
>> I get an unexpected result inside the second foreach() loop. 
>> Anyone know your reason?
>>
> It's my fault, here is the solution:
> ```d
>   foreach(fun; funs)
>   {
> 	range.map!(a => fun(a))
> 	     .reduce!sum
> 	     .write(" "); // Ok!
>   }
>   writeln; // "1115 188 102 86 47"
> ```

With the original version, I'm getting expected results with 
2.098.1. run.dlang.io with 'dmd' also shows expected results.


More information about the Digitalmars-d-learn mailing list