Anonymous user
Entropy: Difference between revisions
→{{header|Crystal}}
(add Crystal example; translated from Python) |
|||
Line 687:
hist = {} of Char => Int32
l = 0
source.each_char do |e|
if !hist.has_key? e
hist[e] = 0
end
hist[e] += 1
end
return Tuple.new(source.size, hist)
|