From: Ramakrishnan Muthukrishnan Date: Fri, 26 Dec 2014 10:35:19 +0000 (+0530) Subject: hw8: exercise 5 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz/frontends/something?a=commitdiff_plain;h=fbef7498fb81291f5dea089918ed54770c0e782f;p=yorgey.git hw8: exercise 5 --- diff --git a/hw8/Party.hs b/hw8/Party.hs index 3bc5e1b..8433006 100644 --- a/hw8/Party.hs +++ b/hw8/Party.hs @@ -4,6 +4,7 @@ module Party where import Data.Monoid import Employee import Data.Tree +import qualified Data.List as L -- exercise 1 -- glCons - a naive way to add an employee to a guest list @@ -60,3 +61,18 @@ maxFun = uncurry moreFun . maxFunPair maxFunPair :: Tree Employee -> (GuestList, GuestList) maxFunPair (Node e es) = nextLevel e $ map maxFunPair es +-- exercise 5 +-- main + +sortedGL :: GuestList -> (Integer, [String]) +sortedGL (GL empls funval) = (funval, L.sort $ map empName empls) + +getEmployeeList :: String -> String +getEmployeeList empls = let (f, ls) = sortedGL (maxFun (read empls)) + in + unlines $ show f : ls + +main :: IO () +main = do + empls <- readFile "company.txt" + putStrLn $ getEmployeeList empls