Created
June 21, 2016 08:10
-
-
Save pulcheri/ecfb17be6be0a97ecb6d6a9366c7851a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- solution to Haskell kata | |
-- https://www.codewars.com/kumite/new?group_id=5463fbb024b6c287a0000016&review_id=5463fbb024b6c287a0000014 | |
module IPv4 where | |
import Data.List (intercalate) | |
import Data.Word (Word32) | |
import Data.Int (Int32) | |
import Data.Bits ((.&.), shiftR) | |
type IPString = String | |
int32ToIP :: Int32 -> IPString | |
int32ToIP x = intercalate "." $ map (\n -> show $ w `shiftR` n .&. 0xff) [24,16..0] | |
where w = (fromIntegral x) :: Word32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment