Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
Sorting algorithms/Insertion sort (view source)
Revision as of 05:17, 7 February 2008
, 16 years agoadded ocaml
(→{{header|Prolog}}: Added spaces to have one verbatim block) |
(added ocaml) |
||
Line 117:
}
}
=={{header|OCaml}}==
let rec insert x = function
[] -> [x]
| y :: ys ->
if x <= y then x :: y :: ys
else y :: insert x ys
;;
let insertion_sort lst = List.fold_right insert lst [];;
insertion_sort [6;8;5;9;3;2;1;4;7];;
=={{header|Prolog}}==
|