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.0.tbz
sha256=388149857c0fbaf2489b1e396af25aadd6185998847b75570f9198a077ad1ace
sha512=9ffa701f7729f90976594c4ec77b968f15450d8d7a1f0c65fe60d092c136b18f1c8bbd5f5772a651c925dabcdc82ac7023c30a4caa1b94e3e158ef2efa34b85e

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