Sha256: 47a1234625d4ed997511eb7eff64d992e10c6204fe9457be3ed3bfdaca7ea061

Contents?: true

Size: 379 Bytes

Versions: 68

Compression:

Stored size: 379 Bytes

Contents

open Base

let find xs value = 
  let rec go lo hi = 
    if lo > hi then None
    else begin 
      let mid = lo + (hi - lo) / 2 in
      let mid_val = xs.(mid) in
      if mid_val < value
      then go (mid + 1) hi
      else if mid_val > value
      then go lo (mid - 1)
      else Some mid
    end
  in
  if Array.is_empty xs
  then None
  else go 0 (Array.length xs - 1) 
  

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.179 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.178 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.177 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.176 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.175 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.174 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.173 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.172 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.171 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.170 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.169 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.167 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.166 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.165 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.164 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.163 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.162 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.161 tracks/ocaml/exercises/binary-search/example.ml
trackler-2.2.1.160 tracks/ocaml/exercises/binary-search/example.ml