(********************************************************************) (* 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 96 on page 395 Heapsort on lists *) let heapsort l = let h = Heap.create () in List.iter (fun x -> Heap.add x h) l; let res = ref [] in while not (Heap.is_empty h) do let x = Heap.get_min h in Heap.remove_min h; res := x :: !res done; !res
This document was generated using caml2html