From: Neil Smith Date: Sun, 4 Dec 2022 10:42:20 +0000 (+0000) Subject: Point-free disjoint X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=e999b6f2ed5c79428eb3842a5e13553370c5f9c3;p=advent-of-code-22.git Point-free disjoint --- diff --git a/advent04/Main.hs b/advent04/Main.hs index 456b157..a295abf 100644 --- a/advent04/Main.hs +++ b/advent04/Main.hs @@ -40,13 +40,14 @@ hasContainment (assignment1, assignment2) = disjoint (assignment1, assignment2) = (assignment1 `before` assignment2) || (assignment2 `before` assignment1) -overlaps pair = not $ disjoint pair +overlaps = not . disjoint contains, before :: Assignment -> Assignment -> Bool contains (Assignment lower1 upper1) (Assignment lower2 upper2) = (lower1 <= lower2) && (upper1 >= upper2) -before (Assignment _lower1 upper1) (Assignment lower2 _upper2) = (upper1 < lower2) +before (Assignment _lower1 upper1) (Assignment lower2 _upper2) = + (upper1 < lower2) -- Parse the input file