blob: 686a7f6d5f82d37f154d27a521cd7fee9797396d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);;
|