diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-04-16 20:25:55 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-04-16 20:25:55 +0900 |
| commit | 2385aacb1237295a4eacade285e6bc3b542ad06f (patch) | |
| tree | eb97f25db2fd31bf2bad59d68e257abaa08c02ff /comparison/OCaml/bsort40000.ml | |
| parent | e273a97d97c9d163bf1ef914cb4659a2593fbdd0 (diff) | |
| download | inpla-2385aacb1237295a4eacade285e6bc3b542ad06f.tar.gz inpla-2385aacb1237295a4eacade285e6bc3b542ad06f.zip | |
Benchmarks for OCaml
Diffstat (limited to 'comparison/OCaml/bsort40000.ml')
| -rw-r--r-- | comparison/OCaml/bsort40000.ml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/comparison/OCaml/bsort40000.ml b/comparison/OCaml/bsort40000.ml new file mode 100644 index 0000000..45744bd --- /dev/null +++ b/comparison/OCaml/bsort40000.ml @@ -0,0 +1,23 @@ +let rec bs (alist : int list) n = + match alist with + (x::y::ys) -> + if x<y then x::(bs (y::ys) (n-1)) + else y::(bs (x::ys) (n-1)) + | xs -> xs;; + + +let rec go xs n = + match n with + 0 -> xs + | n -> go (bs xs n) (n-1);; + +let bsort xs = go xs (List.length(xs) - 1);; + + +let rec mkRandList n = + match n with + 0 -> [] + | n -> (Random.int 10000)::(mkRandList (n-1));; + +let main = bsort (mkRandList 40000);; + |
