anchor.diff:                        % fetch additional past data
                         [S] = fetch_data([S0#series.target], From-(WindowPoints * Step), Until, Now),
                         Values = moving_average(S#series.values, WindowPoints),
  -                      WithTimestamps = with_timestamps(Values, S0#series.start, S#series.step),
  -                      S#series{values=WithTimestamps, start=S0#series.start, until=S0#series.until}
  +                      S0#series{values=Values}
                 end, Series);
   
   % multiplySeries
  
positive.code:            (A, B) -> <<A/binary, ".", B/binary>>
          end,
      lists:foldr(F, <<>>, Parts).
  
  
  with_timestamps(Values, Start, Step) ->
      with_timestamps(Values, Start, Step, []).
  
  with_timestamps([], Start, Step, Acc) ->
      lists:reverse(Acc);
  with_timestamps([V | Vs], Start, Step, []) ->
      with_timestamps(Vs, Start, Step, [{Start, V}]);
  with_timestamps([V | Vs], Start, Step, [{TS, _} | _] = Acc) ->
      with_timestamps(Vs, Start, Step, [{TS + Step, V} | Acc]).
  
  
  safe_average(Values) ->
  
negative.code: safe_tail(Rem, [_ | Xs]) -> safe_tail(Rem - 1, Xs).
  
  
  safe_last([]) -> [];
  safe_last([X]) -> X;
  safe_last([_ | Xs]) -> safe_last(Xs).
  
  
  safe_avg(_Sum, Len) when Len =< 0 -> 0;
  safe_avg(Sum, Len) -> Sum / Len.
  
  