From 4c9c95b6a0ac8aa31abb1f7ab48c3f645c059bd6 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Wed, 20 Mar 2019 17:32:00 +0100 Subject: ocaml byterunner example --- test/monniaux/ocaml/examples/quicksort.ml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/monniaux/ocaml/examples/quicksort.ml (limited to 'test/monniaux/ocaml/examples/quicksort.ml') 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(); -- cgit