From 2385aacb1237295a4eacade285e6bc3b542ad06f Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sat, 16 Apr 2022 20:25:55 +0900 Subject: Benchmarks for OCaml --- comparison/OCaml/qsort800000.ml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 comparison/OCaml/qsort800000.ml (limited to 'comparison/OCaml/qsort800000.ml') diff --git a/comparison/OCaml/qsort800000.ml b/comparison/OCaml/qsort800000.ml new file mode 100644 index 0000000..627abd2 --- /dev/null +++ b/comparison/OCaml/qsort800000.ml @@ -0,0 +1,30 @@ +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 main = qsort (mkRandList 800000) ;; + +(* +The following error arises: + +Stack overflow during evaluation (looping recursion?). +*) -- cgit v1.2.3