First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
8
Task/Entropy/Haskell/entropy.hs
Normal file
8
Task/Entropy/Haskell/entropy.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import Data.List
|
||||
|
||||
main = print $ entropy "1223334444"
|
||||
|
||||
entropy s =
|
||||
sum . map lg' . fq' . map (fromIntegral.length) . group . sort $ s
|
||||
where lg' c = (c * ) . logBase 2 $ 1.0 / c
|
||||
fq' c = map (\x -> x / (sum c)) c
|
||||
Loading…
Add table
Add a link
Reference in a new issue