Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-07-18 at 08:41 +, Anton Fediushin via Digitalmars-d-learn wrote: > On Tuesday, 18 July 2017 at 03:36:04 UTC, Nicholas Wilson wrote: > > With regards to parallel, only use it on the outermost loop. > > Assuming you have more items in the outermost loop than you do > > threads

Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-07-18 at 03:36 +, Nicholas Wilson via Digitalmars-d-learn wrote: > On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: > > […] > > > > Also, I have a question about running this in parallel: if I > > want to use nested loops with `parallel` from > >

Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Anton Fediushin via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 03:36:04 UTC, Nicholas Wilson wrote: With regards to parallel, only use it on the outermost loop. Assuming you have more items in the outermost loop than you do threads parallelising more than one loop won't net you any speed. Thank you! Yes, `parallel` runs only

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: 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 } } }

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:55:47 UTC, Anton Fediushin wrote: Thank you! I knew it is in the library! So, `parallel` will work just fine with this function, isn't it? Yes

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Anton Fediushin via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:32:45 UTC, Sebastiaan Koppe wrote: On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: Hello! What is the best way of rewriting this code in idiomatic D manner? https://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct Thank you! I knew

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: Hello! What is the best way of rewriting this code in idiomatic D manner? https://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct