On Fri, 26 Feb 2010 10:49:30 -0500, Norbert Nemec <[email protected]> wrote:

Ary Borenszweig wrote:
Norbert Nemec wrote:
Hi everybody,

thinking about array expressions, I have stumbled over an interesting challenge for which I still have no idea:

Consider the mathematical sum notation:

    \sum_i a_i*b_i

here, the variable i is defined only at the scope inside the expression.

A analogous D syntax could be something like

    sum!(i)(a[i]*b[i])

where sum would have to be some kind of template that takes i as a name parameter and then defines it as variable inside the scope of the second expression.
 You are missing i's initial and ending values.
 I think it should be something like:
 sum!("i", 0, n)(a[i]*b[i])

I assumed them to default to the array boundaries, but that does not really matter at this point.

Detecting those array boundaries is not an easy task. For example, if you take the expression in as a delegate you can't detect which ranges are used in it.

Reply via email to