Skip to content

Instantly share code, notes, and snippets.

View arbuztw's full-sized avatar
🍉

Yu-Hsi Chiang arbuztw

🍉
View GitHub Profile
import Data.Bool
histogram :: [Int] -> String
histogram xs = unlines . reverse . (['0'..'9']:) . ("==========":) . map (flip map counts . (bool ' ' '*' .) . (<=)) $ [1..height]
where
counts = map (flip ((length.) . filter) xs . (==)) [0..9]
height = maximum counts