From 91d0fb46bc641b1f07db87d9c3ab3d712081c07f Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Wed, 6 Dec 2017 22:26:30 -0800 Subject: [PATCH] Day 7, part 1 - minor adjustments --- 7.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/7.hs b/7.hs index 4bc1270..f6ef944 100644 --- a/7.hs +++ b/7.hs @@ -1,11 +1,9 @@ import Data.HashSet (Set, fromList, delete) import Data.List.Split -import Debug.Trace type Weight = Int type Program = String type Programs = [Program] ---type Tree = Map Program (Weight, Programs) discardEmpty :: [String] -> [String] discardEmpty [""] = [] @@ -21,11 +19,11 @@ parseLine line = main :: IO () main = do input <- readFile "7.txt" - let list = map parseLine $ lines input - names = fromList $ map (\(name, _, _) -> name) list - bottom = foldr (\(name, _, programs) set -> + let list = map parseLine $ lines input + nameSet = fromList $ map (\(name, _, _) -> name) list + bottom = foldr (\(name, _, programs) set -> case programs of [] -> delete name set ps -> foldr delete set ps) - names list + nameSet list print $ bottom \ No newline at end of file