A little challenge...

Norbert Nemec Norbert at Nemec-online.de
Fri Feb 26 00:58:59 PST 2010


Robert Jacques wrote:
> Well there is std.algorithm's map and reduce. Somehow, I feel slicing, 
> ranges/generators and array expressions should be able to handle this. 
> For example: \sum_i i*a_i*b_i-1 => sum(iota * a * b[1..$]) But then 
> again I'm having trouble thinking of real examples off the top of my head.

In fact, that is the way you would do it in e.g. Python/NumPy. It works 
fine for many common cases but does not scale up to more complex 
situations. The mathematical sum notation scales up arbitrarily and 
remains clear.

I would want to offer both options and leave it to the user to choose 
the more appropriate notation.



More information about the Digitalmars-d mailing list