anchor.diff:  safe_tail(Rem, [_ | Xs]) -> safe_tail(Rem - 1, Xs).
   
   
  +safe_avg(_Sum, Len) when Len =< 0 -> 0;
  +safe_avg(Sum, Len) -> Sum / Len.
  +
  +
   moving_average([], _Window) -> [];
   moving_average(Values, Window) when Window =< 0 -> Values;
   moving_average(Values, Window) ->
       FirstPart = lists:sublist(Values, Window),
       FirstLen = safe_length(FirstPart),
       FirstSum = safe_sum(FirstPart),
  -    FirstAvg = FirstSum / FirstLen,
  +    FirstAvg = safe_avg(FirstSum, FirstLen),
       Rest = safe_tail(Window, Values),
       lists:reverse(moving_average(Rest, Values, FirstSum, FirstLen, [FirstAvg])).
   
  
positive.code:     end;
  
  % movingAverage
  evaluate_call(<<"movingAverage">>, [Series, Window], _From, _Until, _Now) when is_binary(Window) ->
      Offset = statser_util:parse_unit(Window),
      % TODO: fetch new data with `Offset` set back
      lists:map(fun(S) ->
                        WindowPoints = Offset / S#series.step,
                        S
                end, Series);
  
  % multiplySeries
  
negative.code:     {Sum1, Len1} = with_current_value(X),
      NewSum = Sum + Sum0 + Sum1,
      NewLen = Len + Len0 + Len1,
      Avg = safe_avg(NewSum, NewLen),
      moving_average(Xs, Ls, NewSum, NewLen, [Avg | Acc]).
  
  
  