(********************************************************************) (* OCaml code from the book ``Learn Programming with OCaml'' *) (* See https://usr.lmf.cnrs.fr/lpo/ *) (* *) (* Sylvain Conchon and Jean-Christophe Filliâtre *) (* Copyright 2025 Université Paris-Saclay and CNRS *) (* *) (* Openly licensed via CC BY SA 4.0 *) (* See https://creativecommons.org/licenses/by-sa/4.0/deed.en *) (********************************************************************) (* Program 90 on page 379 Insertion sort on arrays *) let insertion_sort a = for i = 1 to Array.length a - 1 do let v = a.(i) in let j = ref i in while 0 < !j && lt v a.(!j - 1) do a.(!j) <- a.(!j - 1); decr j done; a.(!j) <- v done
This document was generated using caml2html