(********************************************************************) (* 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 23 on page 178 Iteration Over the Set Bits of a Bit Vector *) let iteri_true f v = Array.iteri (fun i ei -> let index = i * bpi in let rec visit x = if x <> 0 then begin let b = x land -x in f (index + ntz b); visit (x - b) end in visit ei) v.bits
This document was generated using caml2html