Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,9 +1,10 @@
|
|||
let rec insert x = function
|
||||
[] -> [x]
|
||||
| y :: ys ->
|
||||
if x <= y then x :: y :: ys
|
||||
else y :: insert x ys
|
||||
let rec insert lst x =
|
||||
match lst with
|
||||
[] -> [x]
|
||||
| y :: ys when x <= y -> x :: y :: ys
|
||||
| y :: ys -> y :: insert ys x
|
||||
|
||||
;;
|
||||
let insertion_sort lst = List.fold_right insert lst [];;
|
||||
let insertion_sort = List.fold_left insert [];;
|
||||
|
||||
insertion_sort [6;8;5;9;3;2;1;4;7];;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue