Skip to content

Commit b4437ed

Browse files
committed
Refactor 526989a41034285187000de4
1 parent d161463 commit b4437ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Kyu5/IpsBetween.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Kyu5.IpsBetween where
22

3+
import Data.Bits
34
import Data.List.Split (splitOn)
45

56
type Ipv4 = String
@@ -8,4 +9,4 @@ ipsBetween :: Ipv4 -> Ipv4 -> Int
89
ipsBetween from to = to32Bit to - to32Bit from
910

1011
to32Bit :: Ipv4 -> Int
11-
to32Bit ip = foldl (\acc x -> acc * 256 + x) 0 $ map read $ splitOn "." ip
12+
to32Bit ip = foldl (\acc x -> acc `shiftL` 8 .|. x) 0 $ map read $ splitOn "." ip

0 commit comments

Comments
 (0)