Sha256: 9b9d2c09c5495a1263fc8dea0087f5c45b8078496f446e1274f37c60c6749a4b
Contents?: true
Size: 269 Bytes
Versions: 1
Compression:
Stored size: 269 Bytes
Contents
class Array def mode if self.length <= 1 return self end seen = Hash.new(0) self.each{ |value| seen[value] += 1 } max = seen.values.max seen.find_all{ |key, value| value == max }.map{ |key, value| key }.sort end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rstat-0.1.2 | lib/rstat/core_ext/array/descriptive_statistics/location/mode.rb |