movingFn function

generic fn that computes the "fn" on a moving window