From 8c7809d024e85d0a8acfb794a4db41b0e4bc13e6 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Mon, 2 May 2022 09:49:01 +0900 Subject: v0.8.2-1 --- comparison/OCaml/qsort260000.ml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 comparison/OCaml/qsort260000.ml (limited to 'comparison/OCaml/qsort260000.ml') diff --git a/comparison/OCaml/qsort260000.ml b/comparison/OCaml/qsort260000.ml new file mode 100644 index 0000000..983ad50 --- /dev/null +++ b/comparison/OCaml/qsort260000.ml @@ -0,0 +1,38 @@ +open Format + +let rec split pivot (alist : int list) = + match alist with + [] -> ([], []) + | (x::xs) -> + let (below, above) = split pivot xs in + if x [] + | pivot::rest -> + let (below, above) = split pivot rest + in (qsort below) @ [pivot] @ (qsort above) ;; + + + + +let rec mkRandList n = + match n with + 0 -> [] + | n -> (Random.int 10000)::(mkRandList (n-1)) ;; + + +let rec validation alist = + let rec validation_cons x blist = + match blist with + [] -> true + | y::ys -> if x<=y then (validation_cons y ys) else false + in + match alist with + [] -> true + | x::xs -> validation_cons x xs;; + + +let () = print_bool (validation (qsort (mkRandList 260000)));; -- cgit v1.2.3