D for project in computational chemistry

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 4 11:56:18 PDT 2015


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?



More information about the Digitalmars-d mailing list