Sha256: e8dd57afc9fc9f20506285a96ebe2357e35cad9769de2a9cc891c5be6d9132b5

Contents?: true

Size: 255 Bytes

Versions: 7

Compression:

Stored size: 255 Bytes

Contents

module FeCoreExt::CoreExt
end

module FeCoreExt::CoreExt::Array
  def median
    return if empty?
    sorted = sort
    len = sorted.length
    (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
  end
end

class Array
  include FeCoreExt::CoreExt::Array
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fe_core_ext-0.1.11 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.8 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.7 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.6 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.5 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.3 lib/fe_core_ext/core_ext/array.rb
fe_core_ext-0.1.2 lib/fe_core_ext/core_ext/array.rb