[ create a new paste ] login | about

Link: http://codepad.org/qLvbkTO3    [ raw code | output | fork ]

jleedev - Haskell, pasted on Mar 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import Char (intToDigit)
import Numeric (showIntAtBase)
import Data.Word

cletus :: Word8 -> Word8
cletus x = round $ (fromIntegral x) * 255 / 31

test :: (Word8 -> Word8) -> [Word8]
test f = map f [0..31]

showBin :: Word8 -> String
showBin x = f $ showIntAtBase 2 intToDigit x []
        where f = until (\x -> length x >= 8) ('0':)

main :: IO ()
main = mapM_ (putStrLn . showBin) (test cletus)


Output:
00000000
00001000
00010000
00011001
00100001
00101001
00110001
00111010
01000010
01001010
01010010
01011010
01100011
01101011
01110011
01111011
10000100
10001100
10010100
10011100
10100101
10101101
10110101
10111101
11000101
11001110
11010110
11011110
11100110
11101111
11110111
11111111


Create a new paste based on this one


Comments: