Created
May 4, 2018 04:07
-
-
Save shhyou/087a8558908ee4593f4eb5f7e447cfc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Data.List | |
| import Data.Bool | |
| histogramListComp ns = intercalate "\n" [[bool ' ' '*' (x `elem` ys) | x <- [0..9]] | ys <- reverse (transpose (group (sort ns)))] ++ "\n==========\n0123456789\n" | |
| histogramCrypticRowMajor = (++ "\n==========\n0123456789\n") . intercalate "\n" . map (zipWith ($) (map ((bool ' ' '*' .) . elem) [0..9]) . repeat) . reverse . transpose . group . sort | |
| histogramCrypticColMajorBuggy = (++ "\n==========\n0123456789\n") . intercalate "\n" . filter ('*' `elem`) . reverse . transpose . map ((++ replicate 1000 ' ') . (`replicate` '*')) . zipWith ($) (map ((length .) . filter . (==)) [0..9]) . repeat | |
| _ = histogramListComp [1,4,5,4,6,6,3,4,2,4,9] | |
| _ = histogramCrypticRowMajor [1,4,5,4,6,6,3,4,2,4,9] | |
| _ = histogramCrypticColMajorBuggy [1,4,5,4,6,6,3,4,2,4,9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment