Created
November 18, 2014 10:59
-
-
Save robertberry-zz/48a1073575ad8bc67c89 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 (groupBy) | |
import Data.Function (on) | |
section :: String -> String | |
section = takeWhile (/= ',') | |
groupBySection :: [String] -> [[String]] | |
groupBySection = groupBy ((==) `on` section) | |
top15 :: [String] -> [String] | |
top15 lines = concatMap (take 15) (groupBySection lines) | |
io f = interact (unlines . f . lines) | |
main :: IO () | |
main = io top15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment