diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:53 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:53 +0900 |
| commit | e9db0870164cfec10aa219cc0898c30f6a888f53 (patch) | |
| tree | 262150d7ad6abc6759f41a7adbb6dec4a7c90cb5 /comparison/OCaml/isort20000.ml | |
| parent | bd540962efa674bb70dc9ada49393db54616dcbf (diff) | |
| parent | e18b27f43ac23689822d4aaaaa3e8d550e41017a (diff) | |
| download | inpla-e9db0870164cfec10aa219cc0898c30f6a888f53.tar.gz inpla-e9db0870164cfec10aa219cc0898c30f6a888f53.zip | |
Merge branch 'develop'
Diffstat (limited to 'comparison/OCaml/isort20000.ml')
| -rw-r--r-- | comparison/OCaml/isort20000.ml | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/comparison/OCaml/isort20000.ml b/comparison/OCaml/isort20000.ml new file mode 100644 index 0000000..ddcdd2a --- /dev/null +++ b/comparison/OCaml/isort20000.ml @@ -0,0 +1,36 @@ +open Format + +let rec insert x ylist = + match ylist with + [] -> [x] + | y::ys -> if x<=y + then x::y::ys + else y::(insert x ys);; + + +let rec isort (alist : int list) = + match alist with + [] -> [] + | x::xs -> insert x (isort xs);; + + + +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 (isort (mkRandList 20000)));; + |
