Sha256: 6e13870852c5aca1f01a5f31d68f3e822ebc090e0d06f15dd99765cfc78973c9
Contents?: true
Size: 309 Bytes
Versions: 4
Compression:
Stored size: 309 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
4 entries across 4 versions & 2 rubygems