From: Neil Smith Date: Sat, 1 Dec 2018 13:42:26 +0000 (+0000) Subject: Part 2 point-free X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=63a1cfb10f4c516479a41c48ca446a653266da50;p=advent-of-code-18.git Part 2 point-free --- diff --git a/src/advent01/advent01.hs b/src/advent01/advent01.hs index d833bbc..e1935f4 100644 --- a/src/advent01/advent01.hs +++ b/src/advent01/advent01.hs @@ -26,7 +26,7 @@ part1 :: [Int] -> Int part1 = sum part2 :: [Int] -> Int -part2 changes = snd $ head $ dropWhile unRepeated $ scanl merge (S.empty, 0) $ cycle changes +part2 = snd . head . dropWhile unRepeated . scanl merge (S.empty, 0) . cycle merge :: (IntSet, Int) -> Int -> (IntSet, Int) merge (frequencies, frequency) change = (S.insert frequency frequencies, frequency + change)