package grace

  1. Overview
  2. Docs
A fancy diagnostics library that allows your compilers to exit with grace

Install

dune-project
 Dependency

Authors

Maintainers

Sources

grace-0.3.0.tbz
sha256=6948979d6ffb5e596773baead81e9ceef36726d6956261bdd62abb2666a45bfc
sha512=db8b39cc9a77d919ab3123bb4047bb6c672c61db9fc6810951e267b2b113c4ac07266ef57188c6db0c02cb4d43d054204cd66ebc91648dbd1da1228022b0e67b

doc/src/grace.std/binary_search.ml.html

Source file binary_search.ml

1
2
3
4
5
6
7
8
9
10
11
let find_last_satisfying t ~pred ~get ~length =
  let rec loop ~lo ~hi =
    if lo >= hi
    then lo - 1
    else (
      let mid = lo + ((hi - lo) / 2) in
      if pred (get t mid) then loop ~lo:(mid + 1) ~hi else loop ~lo ~hi:mid)
  in
  let idx = loop ~lo:0 ~hi:(length t) in
  if idx < 0 then None else Some idx
;;