Onglet 1
let rec compress l = match l with
|[] -> []
|[a] -> [a]
|a::b::c ->
if a = b then compress(b::c) else a::(compress (b::c)) ;;
let rec pack l =
let rec aux k liste = match k,liste with
|_,[] -> []
|k,[c] -> [List.init k (fun i -> c)]
|_,c::d -> if List.hd(d)=c then aux (k+1) d else (List.init k (fun i -> c))::(pack d);
in aux 1 l;;
let rec replicate l k = match l with
|[] -> []
|a::b -> let rec aux i c liste = match i with
|0 -> liste
|j -> c::(aux (j-1) c liste)
in aux k a (replicate b k);;
let rec drop l k =
let rec aux liste j = match liste,j with
|[],_ -> []
|a::b,1 -> aux b k
|a::b,j -> a::(aux b (j-1));
in aux l k;;
let rec extract k l = match k,l with
|0,_ -> [[]]
|_,[] -> []
|1,[a] -> [[a]]
|k,(a::b) -> (extract k b)@(List.map (fun x -> a::x) (extract (k-1) b));;
Onglet 2