aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/ocaml/examples/quicksort.ml
blob: 57ca5a038920577541d1854db4147b1497837cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
let rec quicksort gt = function
  | [] -> []
  | x::xs ->
      let ys, zs = List.partition (gt x) xs in
      (quicksort gt ys) @ (x :: (quicksort gt zs));;
 
let l =
  quicksort ( > ) [4; 65; 2; -31; 0; 99; 83; 782; 1]
in
List.iter (fun x -> Printf.printf "%d; " x) l;
print_newline();