Is there a built-in lagged operator function in julia? I.e., a function of the form:
lagop(op,array,offset)
that returns something like
[array[i + offset] (op) array[i] for i in 1:length(array)-offset]
For successive differences, there is the diff function. For sums either of the following works:
x = collect(1:10)
x[1:end-1]+x[2:end]
[x[i]+x[i+1] for i in 1:length(x)-1]
Is there a general function to accomplish tasks like this?
lagop(op,array,offset) = [op(array[i + offset], array[i]) for i in 1:length(array)-offset]is not enough? - Lisorollapplyfunction in theRpackagezoo. - Richard Border