Documentation

CslibFrontier.Foundations.Data.List.UnaryCode

Unary coding of natural numbers #

The delimiter-terminated unary code unaryCode n = 1ⁿ 0 encodes natural numbers as Boolean words such that concatenations of encoded words are uniquely decodable (flatMap_unaryCode_injective).

Main definitions #

Main results #

The unary code of a natural number: n letters true followed by false. Distinct sequences of numbers have distinct concatenated codes.

Within a unary block of true bits followed by false, the bits are set before the end of the block.

After a unary block of m true bits followed by false, the bits are those of the rest.