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/msort800000.ml | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 comparison/OCaml/msort800000.ml (limited to 'comparison/OCaml/msort800000.ml') diff --git a/comparison/OCaml/msort800000.ml b/comparison/OCaml/msort800000.ml new file mode 100644 index 0000000..1835b98 --- /dev/null +++ b/comparison/OCaml/msort800000.ml @@ -0,0 +1,43 @@ +let rec split (alist : int list) = + match alist with + [] -> ([], []) + | [a] -> ([a], []) + | a::b::cs -> + let (m,n) = split cs in + (a::m, b::m) ;; + +let rec merge (alist : int list) (blist : int list) = + match alist with + [] -> blist + | x::xs -> + match blist with + [] -> x::xs + | y::ys -> + if x [] + | a::[] -> [a] + | a::b::[] -> if a + let (m,n) = split xs + in merge (msort m) (msort n) ;; + + + +let rec mkRandList n = + match n with + 0 -> [] + | n -> (Random.int 10000)::(mkRandList (n-1)) ;; + +let main = msort (mkRandList 800000) ;; + + +(* +The following error arises: + +Stack overflow during evaluation (looping recursion?). +*) -- cgit v1.2.3