Hello! What is the best way of rewriting this code in idiomatic D manner?
------
foreach(a; ["foo", "bar"]) {
  foreach(b; ["baz", "foz", "bof"]) {
    foreach(c; ["FOO", "BAR"]) {
      // Some operations on a, b and c
    }
  }
}
------

Every array has at least 1 element, and adding/removing new "nested loops" should be as easy as possible.

Also, I have a question about running this in parallel: if I want to use nested loops with `parallel` from `std.parallelism`, should I add `parallel` to every loop like this?
------
foreach(a; ["foo", "bar"].parallel) {
  foreach(b; ["baz", "foz", "bof"].parallel) {
    foreach(c; ["FOO", "BAR"].parallel) {
      // Some operations on a, b and c
    }
  }
}
------
I am worried about running thousands of threads, because in this case first `parallel` runs 2 tasks, every task runs 3 tasks and every task runned inside a task runs 2 more tasks.

So, how to write this in idiomatic D manner and run it _if possible_ in parallel?

Reply via email to