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

Version Path
facets-2.8.4 lib/core/facets/enumerable/frequency.rb
facets-2.8.3 lib/core/facets/enumerable/frequency.rb
facets-2.8.2 lib/core/facets/enumerable/frequency.rb
facets-2.8.1 lib/core/facets/enumerable/frequency.rb
facets-2.8.0 lib/core/facets/enumerable/frequency.rb
facets-2.7.0 lib/core/facets/enumerable/frequency.rb
facets-2.6.0 lib/core/facets/enumerable/frequency.rb
facets-2.5.0 lib/core/facets/enumerable/frequency.rb
facets-2.5.1 lib/core/facets/enumerable/frequency.rb
facets-2.5.2 lib/core/facets/enumerable/frequency.rb