def calculate(array)
      return [] if @span > array.length
      
      array.each_cons(@span).map do |window|
        window.zip(weights).map {|(a,b)| a * b }.inject(&:+)
      end
    end
def calculate(array)
      return [] if @span > array.length
      
      array.each_cons(@span).map do |window|
        window.zip(weights).map {|(a,b)| a * b }.inject(&:+)
      end
    end
Creates a new MovingAverage given a list of weights.

 See also the class methods simple and weighted.
 Calculates the moving average for the given array of numbers.

 Moving averages won't include values for terms at the beginning or end of
 the array, so there will be fewer numbers than in the original.