-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Gray code encoder/decoder. -- -- Gray code is a binary numeral system where two successive numbers -- differ in only one bit. This package allows to convert Haskell numbers -- to one of the possible Gray codes and back. @package gray-code @version 0.1 -- | Gray code is a binary numeral system where two successive numbers -- differ in only one bit. module Codec.Binary.Gray -- | Takes a list of bits (most significant last) in binary encoding and -- converts them to Gray code. -- -- Algorithm: Haupt, R.L. and Haupt, S.E., Practical Genetic Algorithms, -- Second ed. (2004), 5.4. Gray Codes. binaryToGray :: [Bool] -> [Bool] -- | Takes a list of bits in Gray code and converts them to binary encoding -- (most significant bit last). -- -- Algorithm: Haupt, R.L. and Haupt, S.E., Practical Genetic Algorithms, -- Second ed. (2004), 5.4. Gray Codes. grayToBinary :: [Bool] -> [Bool] -- | Convert a number to a list of bits in usual binary encoding (most -- significant last). -- -- As bitSize, bitsToBinary is undefined for types that do -- not have fixed bitsize, like Integer. bitsToBinary :: (Bits b) => b -> [Bool] -- | Convert a list of bits in binary encoding to a number. binaryToBits :: (Bits a) => [Bool] -> a -- | Render a list of bits as a 0-1 string. showBinary :: [Bool] -> String