Sha256: 7f0085383642102030c7fc04f4cc69df1df8ac8e40c904c9d71f3ce8cb00d3d9
Contents?: true
Size: 308 Bytes
Versions: 10
Compression:
Stored size: 308 Bytes
Contents
module Enumerable # Generates a hash mapping each unique symbol in the array # to the absolute frequency it appears. # # CREDIT: Brian Schröder def frequency #probs = Hash.new(0) #each do |e| # probs[e] += 1 #end #probs inject(Hash.new(0)){|h,v| h[v]+=1; h} end end
Version data entries
10 entries across 10 versions & 1 rubygems