diff options
Diffstat (limited to 'comparison/OCaml')
| -rw-r--r-- | comparison/OCaml/bsort40000.ml | 14 | ||||
| -rw-r--r-- | comparison/OCaml/isort40000.ml | 22 | ||||
| -rw-r--r-- | comparison/OCaml/msort800000.ml | 16 | ||||
| -rw-r--r-- | comparison/OCaml/qsort800000.ml | 18 |
4 files changed, 52 insertions, 18 deletions
diff --git a/comparison/OCaml/bsort40000.ml b/comparison/OCaml/bsort40000.ml index 45744bd..2a06e85 100644 --- a/comparison/OCaml/bsort40000.ml +++ b/comparison/OCaml/bsort40000.ml @@ -19,5 +19,17 @@ let rec mkRandList n = 0 -> [] | n -> (Random.int 10000)::(mkRandList (n-1));; -let main = bsort (mkRandList 40000);; + +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 main = validation (bsort (mkRandList 40000));; diff --git a/comparison/OCaml/isort40000.ml b/comparison/OCaml/isort40000.ml index 686a7f6..92e127d 100644 --- a/comparison/OCaml/isort40000.ml +++ b/comparison/OCaml/isort40000.ml @@ -1,11 +1,3 @@ -(* -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] @@ -26,5 +18,17 @@ let rec mkRandList n = 0 -> [] | n -> (Random.int 10000)::(mkRandList (n-1));; -let main = isort (mkRandList 40000);; + +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 main = validation(isort (mkRandList 40000));; diff --git a/comparison/OCaml/msort800000.ml b/comparison/OCaml/msort800000.ml index 1835b98..bbb8de6 100644 --- a/comparison/OCaml/msort800000.ml +++ b/comparison/OCaml/msort800000.ml @@ -33,11 +33,19 @@ let rec mkRandList n = 0 -> [] | n -> (Random.int 10000)::(mkRandList (n-1)) ;; -let main = msort (mkRandList 800000) ;; +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;; -(* -The following error arises: +let main = validation (msort (mkRandList 800000));; -Stack overflow during evaluation (looping recursion?). +(* +Fatal error: exception Stack_overflow *) diff --git a/comparison/OCaml/qsort800000.ml b/comparison/OCaml/qsort800000.ml index 627abd2..7547f45 100644 --- a/comparison/OCaml/qsort800000.ml +++ b/comparison/OCaml/qsort800000.ml @@ -21,10 +21,20 @@ let rec mkRandList n = 0 -> [] | n -> (Random.int 10000)::(mkRandList (n-1)) ;; -let main = qsort (mkRandList 800000) ;; -(* -The following error arises: +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;; + -Stack overflow during evaluation (looping recursion?). +let main = validation(qsort (mkRandList 800000));; + +(* +Fatal error: exception Stack_overflow *) |
