Is there a common pattern in Julia (perhaps with some kind of a macro) for the following case?
I have a function that runs a model through several thousands of time steps, and I want to have two versions:
- one where each time-step is saved,
- just a sum over all time steps is computed
As the parameters of this model will be optimized using Optim.jl on many sets, I would like to keep the functions as performant as possible and avoid conditions inside the loop, yet without copy-pasting a large part of code (only two lines are different).