-- moreFun
moreFun :: GuestList -> GuestList -> GuestList
-moreFun g1@(GL _ f1) g2@(GL _ f2) | f1 > f2 = g1
- | otherwise = g2
+moreFun g1 g2 | g1 > g2 = g1
+ | otherwise = g2
-- treeFold :: (Tree a -> b -> b) -> b -> Tree a -> b
-- treeFold combine e= treeDestructor e f
treeFold f e (Node v ts) = let b = foldr (\t acc -> treeFold f acc t) e ts
in
f b v
+-- exercise 3
+-- nextLevel
+-- if the big boss comes, no question, his reportee managers are not
+-- coming. So, we just take the send list from each pair and concat them.
+-- if the big boss is not coming, then we pick the list from the pair that
+-- has most fun and concat them all.
+nextLevel :: Employee -> [(GuestList, GuestList)] -> (GuestList, GuestList)
+nextLevel e lst =
+ let withBoss = glCons e $ mconcat $ map snd lst
+ withoutBoss = mconcat $ map (uncurry moreFun) lst
+ in
+ (withBoss, withoutBoss)