From: Michael Orlitzky Date: Sun, 23 May 2010 16:25:15 +0000 (-0400) Subject: Use min_address to simplify some of the min_host cases. X-Git-Tag: 0.0.1~27 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d34688b75f995d99e112064225735921a8d4ee28;p=hath.git Use min_address to simplify some of the min_host cases. --- diff --git a/src/Cidr.hs b/src/Cidr.hs index 14cefff..41ea9ee 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -138,41 +138,15 @@ min_host (Cidr addr mask) | mask == Nine = addr { octet2 = apply_mask oct2 One, octet3 = min_octet, octet4 = min_octet } - | mask == Eight = addr { octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Seven = addr { octet1 = apply_mask oct1 Seven, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Six = addr { octet1 = apply_mask oct1 Six, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Five = addr { octet1 = apply_mask oct1 Five, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Four = addr { octet1 = apply_mask oct1 Four, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Three = addr { octet1 = apply_mask oct1 Three, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Two = addr { octet1 = apply_mask oct1 Two, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == One = addr { octet1 = apply_mask oct1 One, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } - | mask == Zero = addr { octet1 = min_octet, - octet2 = min_octet, - octet3 = min_octet, - octet4 = min_octet } + | mask == Eight = min_address { octet1 = oct1 } + | mask == Seven = min_address { octet1 = apply_mask oct1 Seven } + | mask == Six = min_address { octet1 = apply_mask oct1 Six } + | mask == Five = min_address { octet1 = apply_mask oct1 Five } + | mask == Four = min_address { octet1 = apply_mask oct1 Four } + | mask == Three = min_address { octet1 = apply_mask oct1 Three } + | mask == Two = min_address { octet1 = apply_mask oct1 Two } + | mask == One = min_address { octet1 = apply_mask oct1 One } + | mask == Zero = min_address | otherwise = addr where oct1 = (octet1 addr)