(********************************************************************) (* 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 51 on page 246 Intersection of Prefix Trees *) let rec inter t1 t2 = { word = t1.word && t2.word; branches = inter_branches t1.branches t2.branches; } and inter_branches m1 m2 = M.fold (fun i ti m -> try let t = inter ti (M.find i m2) in if is_empty t then m else M.add i t m with Not_found -> m) m1 M.empty
This document was generated using caml2html