diff options
Diffstat (limited to 'comparison/OCaml/isort40000.ml')
| -rw-r--r-- | comparison/OCaml/isort40000.ml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/comparison/OCaml/isort40000.ml b/comparison/OCaml/isort40000.ml new file mode 100644 index 0000000..686a7f6 --- /dev/null +++ b/comparison/OCaml/isort40000.ml @@ -0,0 +1,30 @@ +(* +let rec insert x ylist = + match ylist with + [] -> [x] + | y::ys when x<=y -> x::y::ys + | y::ys -> y::(insert x ys);; +*) + +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 main = isort (mkRandList 40000);; + |
