On Tuesday, 4 August 2015 at 18:56:20 UTC, jmh530 wrote:
On Tuesday, 4 August 2015 at 09:48:07 UTC, Chris wrote:
I agree with bachmeier. You cannot go wrong. You mentioned nested loops. D allows you to concatenate (or "pipe") loops. So instead of

foreach
{
  foreach
  {
    foreach
    {
    }
  }
}

you have something like

int[] numbers = [-2, 1, 6, -3, 10];
foreach (ref n; numbers
  .map!(a => a * 5)  // multiply each value by 5
  .filter!(a => a > 0))  // filter values that are 0 or less
{
  //  Do something
}


I don't think I had seen an example like this before (though it is obvious in retrospect). Is there any advantage in terms of performance?

ldc and gdc can often achieve parity with explicit loops.

Reply via email to