Entropy/Narcissist: Difference between revisions

m
(→‎{{header|Haskell}}: Changed to binary analyser)
Line 263:
main = getArgs >>= head >>> BS.readFile >>= BS.unpack >>> entropy >>> print
entropy = sort >>> group >>> map genericLength >>> frequencynormalize >>> map lg >>> sum
where lg c = -c * logBase 2 c
frequencynormalize c = let sc = sum c in map (/ sc) c</lang>
 
{{out}} In a shell
Anonymous user