summaryrefslogtreecommitdiff
path: root/src/util.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.ml')
-rw-r--r--src/util.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.ml b/src/util.ml
index 5ef9686d..6a2fb9bb 100644
--- a/src/util.ml
+++ b/src/util.ml
@@ -386,6 +386,14 @@ let rec take_drop f = function
let (ys, zs) = take_drop f xs in
(x :: ys, zs)
+let find_next f xs =
+ let rec find_next' f acc = function
+ | x :: xs when f x -> List.rev acc, Some (x, xs)
+ | x :: xs -> find_next' f (x :: acc) xs
+ | [] -> List.rev acc, None
+ in
+ find_next' f [] xs
+
let is_none opt = not (is_some opt)
let rec take n xs = match n, xs with