[dmd-concurrency] How to use parallel foreach to process a part of array?

Ilya Sazonov poxvuibr at gmail.com
Tue Oct 29 00:49:10 PDT 2013


Suppose I have the following piece of code

import std.parallelism;

void main() {
    int[] data = new int[1000_000_00];

    foreach(i, ref el; parallel(data)) {
        if (i > 10 && i < 1000_000_00 - 10)
            data[i] = data[i-10] + data[i+10];
    }
}

That's right, I want to process all the elements of the array, except for
first 10 and last 10.
Is there a way to do that without if statement?

I mean something like foreach starting from element with index 10 and
ending with lendth - 10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-concurrency/attachments/20131029/e292cc6b/attachment.html>


More information about the dmd-concurrency mailing list