diff options
Diffstat (limited to 'test/monniaux/ocaml/examples')
-rwxr-xr-x | test/monniaux/ocaml/examples/quicksort | bin | 0 -> 146138 bytes | |||
-rw-r--r-- | test/monniaux/ocaml/examples/quicksort.ml | 11 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/monniaux/ocaml/examples/quicksort b/test/monniaux/ocaml/examples/quicksort Binary files differnew file mode 100755 index 00000000..0b820167 --- /dev/null +++ b/test/monniaux/ocaml/examples/quicksort 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(); |