summaryrefslogtreecommitdiff
path: root/tests/test_runner/Utils.ml
blob: 79be617cc14b256e1d68157cb4e761448e4fdfac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
(*** Convenience functions *)

let map_while (f : 'a -> 'b option) (input : 'a list) : 'b list =
  let _, result =
    List.fold_left
      (fun (continue, out) a ->
        if continue then
          match f a with None -> (false, out) | Some b -> (true, b :: out)
        else (continue, out))
      (true, []) input
  in
  List.rev result