Although preferred way to express iteration is through aggregation functions, we may still encounter loops in 3rd party code and it would be nice to support at least simple ones. One particular example is:
y = 0.0
for x in xs
y += f(x)
end
We have 2 options here:
- Preprocess loops transforming them into aggregation functions. E.g. loop above may be transformed into
sum(f.(x)).
- Translate a derivative of a loop into a loop of derivatives. This is more general-purpose, but looks also much harder to implement.
Although preferred way to express iteration is through aggregation functions, we may still encounter loops in 3rd party code and it would be nice to support at least simple ones. One particular example is:
We have 2 options here:
sum(f.(x)).