From fbef7498fb81291f5dea089918ed54770c0e782f Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Fri, 26 Dec 2014 16:05:19 +0530 Subject: [PATCH] hw8: exercise 5 --- hw8/Party.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 2.37.2