Parallelization of a large array

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 10 15:11:56 PDT 2015


On Tuesday, 10 March 2015 at 21:27:42 UTC, Dennis Ritchie wrote:
> Thanks.

No, it does not suit me, because of the parallel array in a 
foreach loop there is no break.

import std.stdio;
import std.algorithm;
import std.parallelism;

void main() {

	int b = 2;

	auto a = [1, 2, 2, 3];

	if (find(a, b).length != 0)
		writeln("Yes_");

	foreach (elem; a.parallel)
		if (elem == b)
			writeln("Yes");		// prints "Yes" twice
}


More information about the Digitalmars-d-learn mailing list