Sorting algorithms/Insertion sort: Difference between revisions

No edit summary
Line 1,556:
<lang ocaml>let rec insert x = function
[] -> [x]
| y :: ys when x <= y -> x :: y :: ys
| y :: ifys x <=-> y then x :: yinsert ::x ys
 
else y :: insert x ys
;;
let insertion_sort lst = List.fold_right insert lst [];;
Anonymous user