Skip to content

Instantly share code, notes, and snippets.

@robertberry-zz
Created November 18, 2014 10:59
Show Gist options
  • Save robertberry-zz/48a1073575ad8bc67c89 to your computer and use it in GitHub Desktop.
Save robertberry-zz/48a1073575ad8bc67c89 to your computer and use it in GitHub Desktop.
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