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.4.1.tbz
sha256=d49754224206de44855590848b3a5a6cc1d5c46cf99a4e5810ca3041d436a28e
sha512=2984b5a6284bf8bbd05419cf850c15c34bc19c19f0c8928b83cc1be1c0bfc84aafef6d992e7435c2f48ba361a6f3aab679abd02f0e6472361c8cec7d497bc405

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
;;