aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/ocaml/examples/quicksort.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/ocaml/examples/quicksort.ml')
-rw-r--r--test/monniaux/ocaml/examples/quicksort.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/monniaux/ocaml/examples/quicksort.ml b/test/monniaux/ocaml/examples/quicksort.ml
new file mode 100644
index 00000000..57ca5a03
--- /dev/null
+++ b/test/monniaux/ocaml/examples/quicksort.ml
@@ -0,0 +1,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();