Programmation Fonctionnelle, TP3
Racine
Cours
Examen 2018
Correction examen 2018
TD
1. Variables et fonctions
2. Types paramétrés I
3. Types paramétrés II
4. Listes
5. Types algébriques I
6. Types algébriques II
7. Yojson, dictionnaires
8. Modules, foncteurs
9. Boucles fonctionnelles
10. Révisions
TP
1. Legos
2. Jeu du satellite
3. Fractale de Mandelbrot
4. Script et fichiers
5. Arbres binaires
6. Reingold-Tilford
7. OpenStreetMap
8. Le compte est bon
9. Paresse
10. Retour à Java
back to teaching
Version & licenses
Programmation Fonctionnelle, TP3 : binary.mli
Guyslain Naves
(** the type of bits *)
type
bit =
|
O
(** stands for zero *)
|
I
(** stands for one *)
(** [bit_list_of_int value length] converts the integer [value] into a list of bits (little-endian).
[length] is the number of bits of the encoding. [value] is taken modulo 2 to [length] *)
val
bit_list_of_int : int -> int -> bit list
(** [int_of_bit_list lst] converts the little-endian encoding of an integer coded by a list of bits into an int *)
val
int_of_bit_list : bit list -> int
(** [ascii_of_bit_list] converts a list of bits into a list of integer between 0 and 255,
Each block of 8 successive bits is translated to an int. A number of [O] is added at the end
to avoid any overflow.
*)
val
ascii_of_bit_list : bit list -> int list
(** [bit_list_of_ascii] converts an integer between 0 and 255 into a list of 8 bits (little-endian). *)
val
bit_list_of_ascii : int -> bit list
(** [int_list_of_bit_list lit length] converts a list of bits into a list of integer.
The list is cut into blocks of size [length], and each of this block is considered
to be an integer in little-endian notation
*)
val
int_list_of_bit_list : bit list -> int -> int list