A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
3
Task/Letter-frequency/Haskell/letter-frequency-1.hs
Normal file
3
Task/Letter-frequency/Haskell/letter-frequency-1.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Data.List
|
||||
|
||||
main = readFile "freq.hs" >>= mapM_ (\x -> print (head x, length x)) . group . sort
|
||||
8
Task/Letter-frequency/Haskell/letter-frequency-2.hs
Normal file
8
Task/Letter-frequency/Haskell/letter-frequency-2.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import qualified Data.Map as M
|
||||
|
||||
main = do
|
||||
text <- readFile "freq.hs"
|
||||
let result = foldl (flip (M.adjust (+1))) initial text
|
||||
mapM_ print $ M.toList result
|
||||
|
||||
initial = M.fromList $ zipWith (\k v -> (toEnum k,v)) [0..255] (repeat 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue