Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*let insertion vec = function
- for i = 0 to vect_length(vec) do
- let j = ref 1 in
- let val = vec.(i) in
- while vec.(i-j) > val do
- vec.(i-j+1) <-vec.(i-j)
- j := !j + 1
- done;
- vec.(i-j) <- val;
- done;
- for i = 0 to vect_length(vec) do
- print_int(vec.(i))
- end;;
- let vect = make_vect 5 5 in
- vect.(1) <- 3
- vect.(2) <- 1
- insertion vect;;*)
- let rec insererliste liste valeur = match liste with
- | [] -> [valeur]
- | t::q -> if t <= valeur then valeur::(t::q) else t::(insererliste q valeur);;
- let rec insertion liste = match liste with
- | [] -> []
- | [t] -> [t]
- | t::q -> insererliste (insertion q) t;;
- let rec print_list = function
- [] -> ()
- | e::l -> print_int e ; print_string " " ; print_list l;;
- let rec minAux l = match l with
- | [] -> failwith "En fait non.."
- | [t] -> t
- | t::q -> if t < min q then t else min q;;
- let rec minPrive l v = match l with
- | [] -> []
- | [t] -> if t == v then [] else [t]
- | t::q -> if t == v then q else t::(minPrive q v);;
- (*let insertion vec = function
- for i = 0 to vect_length(vec) do
- let j = ref 1 in
- let val = vec.(i) in
- while vec.(i-j) > val do
- vec.(i-j+1) <-vec.(i-j)
- j := !j + 1
- done;
- vec.(i-j) <- val;
- done;
- for i = 0 to vect_length(vec) do
- print_int(vec.(i))
- end;;
- let vect = make_vect 5 5 in
- vect.(1) <- 3
- vect.(2) <- 1
- insertion vect;;*)
- let rec insererliste liste valeur = match liste with
- | [] -> [valeur]
- | t::q -> if t <= valeur then valeur::(t::q) else t::(insererliste q valeur);;
- let rec insertion liste = match liste with
- | [] -> []
- | [t] -> [t]
- | t::q -> insererliste (insertion q) t;;
- let rec print_list = function
- [] -> ()
- | e::l -> print_int e ; print_string " " ; print_list l;;
- let rec minAux l = match l with
- | [] -> failwith "En fait non.."
- | [t] -> t
- | t::q -> if t < min q then t else min q;;
- let rec minPrive l v = match l with
- | [] -> []
- | [t] -> if t == v then [] else [t]
- | t::q -> if t == v then q else t::(minPrive q v);;
- let rec selection l = match l with
- | [] -> []
- | l -> (min l)::(selection (minPrive l (min l)));;
- print_list (selection [3;4;2;1]);;
- let rec passe l = match l with
- | [] -> []
- | [h] -> [h]
- | t1::t2::q -> if t2 > t1 then t2::(t1::(passe q)) else t1::(t2::(passe q));;
- print_list (passe [3;4;1;2]);;
Advertisement
Add Comment
Please, Sign In to add comment