(********************************************************************) (* 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 89 on page 377 Insertion sort on lists *) let rec insert acc x = function y :: l when lt y x -> insert (y :: acc) x l l -> List.rev_append acc (x :: l) let insertion_sort l = List.fold_left (fun r x -> insert [] x r) [] l
This document was generated using caml2html