Programmation Fonctionnelle, TP3

Version & licenses
Creative Commons License

Programmation Fonctionnelle, TP3 : binary.mli

Guyslain Naves
  1. (** the type of bits *)
  2. type bit =
  3. | O (** stands for zero *)
  4. | I (** stands for one *)

  5. (** [bit_list_of_int value length] converts the integer [value] into a list of bits (little-endian).
  6. [length] is the number of bits of the encoding. [value] is taken modulo 2 to [length] *)
  7. val bit_list_of_int : int -> int -> bit list

  8. (** [int_of_bit_list lst] converts the little-endian encoding of an integer coded by a list of bits into an int *)
  9. val int_of_bit_list : bit list -> int

  10. (** [ascii_of_bit_list] converts a list of bits into a list of integer between 0 and 255,
  11. Each block of 8 successive bits is translated to an int. A number of [O] is added at the end
  12. to avoid any overflow.
  13. *)
  14. val ascii_of_bit_list : bit list -> int list

  15. (** [bit_list_of_ascii] converts an integer between 0 and 255 into a list of 8 bits (little-endian). *)
  16. val bit_list_of_ascii : int -> bit list

  17. (** [int_list_of_bit_list lit length] converts a list of bits into a list of integer.
  18. The list is cut into blocks of size [length], and each of this block is considered
  19. to be an integer in little-endian notation
  20. *)
  21. val int_list_of_bit_list : bit list -> int -> int list