Commit cb7dd15a authored by Louis Duchemin's avatar Louis Duchemin
Browse files

Implements toolbox.Utils.range_find

parent 805f6a43
......@@ -37,6 +37,12 @@ let%test "not (range_for_all 1..4 <= 2)" =
let%test "not (range_for_all 1..4 <= 0)" =
not @@ range_for_all 1 4 ~f:(( >= ) 2)
let range_find a b ~f =
let rec loop i =
if i < b then if f i then Some i else loop (i + 1) else None
in
loop a
let int_fold a b ~init ~f =
let rec loop acc i = if i >= b then acc else loop (f acc i) (i + 1) in
loop init a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment