Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -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];;