Hi there,
I have the following problem: I have a time-series with more than 10000 entries and I want to perform some calculations with each of them. This alone wouldn't be a problem, but I need to get the last calculated value in order to get the next one. A very simple form of what I need would look like this:
Val(n) = Val(n-1) + (time-series-entry / 2)
(or something like it!)
I don't have any idea how to manage this. Simply doing something like this:
(defn calc-val
[time-series element]
(seq (cons (generate-val-element time-series element)
(calc-val time-series (inc element)))))
wouldn't work because can't (at least I don't know how!) get the last computed value. Then I thought: OK, let's use Loop-Recur. This would give me the value corresponding to the time-series entry BUT for the next one I would have to do all the computations again. Iterate would be the right thing, but it didn't work because the function has side effects.
So I'm stuck here on this one. It would be great if someone could give me a hint.