Bug introduced in 10.0 and fixed in 10.1
MovingMap
(new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series.
But the error returned by the following code bothers me:
series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]
(* Power::infy: Infinite expression 1/0. encountered. >>\*)
(* {1, 1/2, 1/3, 1/4} *)
However, this code returns the result with no error:
MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]
(* {1, 1/2, 1/3, 1/4} *)
What causes this problem?