Sha256: 56af22dcc9505ec149f0bab6cbad4da3b2583717f15fd7bde4c3b0bf8ee58e27
Contents?: true
Size: 261 Bytes
Versions: 8
Compression:
Stored size: 261 Bytes
Contents
# frozen_string_literal: true module Math def self.average(values) values = values.map { |v| [v, 1] }.to_h unless values.is_a?(Hash) values.inject(0) do |sum, vals| sum + vals.inject { |a, b| a * b } end / values.values.sum.to_f end end
Version data entries
8 entries across 8 versions & 1 rubygems