(* Longueur d'une liste ie List.length *)
let rec length lst =
match lst with
| [] -> 0
| _ :: t -> 1 + length t
(* Vérifie si un élément est dans la liste ie List.mem *)
let rec mem x lst =
match lst with
| [] -> false
| h :: t -> h = x || mem x t
(* Vérifie si un élément satisfait le prédicat ie List.exists *)
let rec exists p lst =
match lst with
| [] -> false
| h :: t -> p h || exists p t
(* Vérifie si tous les éléments satisfont le prédicat ie List.for_all *)
let rec for_all p lst =
match lst with
| [] -> true
| h :: t -> p h && for_all p t
(* Filtre les éléments qui satisfont le prédicat ie List.filter *)
let rec filter p lst =
match lst with
| [] -> []
| h :: t ->
if p h then h :: filter p t
else filter p t
(* Applique une fonction à chaque élément ie List.map *)
let rec map f lst =
match lst with
| [] -> []
| h :: t -> f h :: map f t
(* Concaténation de deux listes ie l'opérateur @ *)
let rec concat l1 l2 =
match l1 with
| [] -> l2
| h :: t -> h :: (concat t l2)