The idea is that a sequence can yield additional information by comparing the neighborhoods around a given point. For this function, a point is an index of the sequence. In the 1D case, given an index k and a radius r, the left neighbohood is defined by [k-r+1, k] and the right neighborhood is defined by [k+1, k+r]. The values associated with each neighborhood are then applied to a metric function m: A^r -> R. This output becomes the coordinate pair (left, right).
At the edges of the sequence the above formalism is not completely accurate. This is because at the edge, the neighborhood will be smaller than the radius, with a minimum size of 1. Hence the first iteration on a sequence will yield a left neighborhood of 1, while the right neighborhood will be [2, 1+r]. Whether this is acceptable is case-specific.
In the future, a wrap parameter might be included that would emulate a loop instead of a sequence. This would be useful if a sequence represented a stationary time series.
partition(1:10, mean, radius=2)
Run the code above in your browser using DataLab