Sha256: 346cd9a9593aee44790b932f54b09b29fc1e37584d92b50a1f7a7ac578753168

Contents?: true

Size: 298 Bytes

Versions: 1

Compression:

Stored size: 298 Bytes

Contents

require 'huffman_coding/utils'

class << HuffmanCoding::Utils
  if Enumerable.method_defined?(:tally)
    def tally(enumerable)
      enumerable.tally
    end
  else
    def tally(enumerable)
      hash = Hash.new(0)
      enumerable.each{|key| hash[key] += 1 }
      return hash
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
huffman_coding-0.0.1 lib/huffman_coding/utils/tally.rb