Simple parallel foreach and summation/reduction
Dennis
dkorpel at gmail.com
Fri Sep 21 08:41:54 UTC 2018
On Friday, 21 September 2018 at 07:25:17 UTC, Chris Katko wrote:
> I get "Error: template instance `reduce!((a, b) => a + b)`
> cannot use local __lambda1 as parameter to non-global template
> reduce(functions...)" when trying to compile that using the
> online D editor with DMD and LDC.
>
> Any ideas?
That's a long standing issue:
https://issues.dlang.org/show_bug.cgi?id=5710
Using a string for the expression does work though:
```
import std.stdio, std.parallelism, std.range;
void main() {
taskPool.reduce!"a + b"(iota(1_000L)).writeln;
}
```
More information about the Digitalmars-d-learn
mailing list