久しぶりに
単なるxor式のチェックサム。ビット操作のサンプル程度に。
module FCS where import Bits import Word toHex :: Int -> Char toHex a = "0123456789ABCDEF" !! a strToFCS :: [Char] -> [Char] strToFCS a = toFCS (xors a) where toFCS :: Int -> [Char] toFCS a = [toHex (a `div` 16), toHex (a `mod` 16)] xors :: [Char] -> Int xors [] = 0 xors (c:cs) = word8ToInt( (intToWord8 (ord c)) `xor` (intToWord8 (xors cs)))