We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f36ac63 commit 2411dc8Copy full SHA for 2411dc8
jscomp/ext/ext_list.ml
@@ -583,7 +583,13 @@ let rec find_opt xs p =
583
| Some _ as v -> v
584
| None -> find_opt l p
585
586
-
+let rec find_def xs p def =
587
+ match xs with
588
+ | [] -> def
589
+ | x::l ->
590
+ match p x with
591
+ | Some v -> v
592
+ | None -> find_def l p def
593
594
let rec split_map l f =
595
match l with
jscomp/ext/ext_list.mli
@@ -259,7 +259,13 @@ val find_opt :
259
('a -> 'b option) ->
260
'b option
261
262
+val find_def :
263
+ 'a list ->
264
+ ('a -> 'b option) ->
265
+ 'b ->
266
+ 'b
267
268
+
269
val rev_iter :
270
'a list ->
271
('a -> unit) ->
0 commit comments