Skip to content

Instantly share code, notes, and snippets.

@arbuztw
Last active May 10, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbuztw/fbf0600b14a09c49472d4ba53480857a to your computer and use it in GitHub Desktop.
Save arbuztw/fbf0600b14a09c49472d4ba53480857a to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment