Permalink
Browse files

[enhance] libbase/List: added assq_opt

  • Loading branch information...
1 parent 5852a63 commit cb74acdea954ffd22688708b7f60c0f3345ca243 Louis Gesbert committed Jul 8, 2011
Showing with 8 additions and 0 deletions.
  1. +7 −0 libbase/baseList.ml
  2. +1 −0 libbase/baseList.mli
View
@@ -362,6 +362,13 @@ let assoc_opt key =
| _::q -> aux q
in aux
+let assq_opt key =
+ let rec aux = function
+ | [] -> None
+ | (k, v)::_ when key == k -> Some v
+ | _::q -> aux q
+ in aux
+
let find_opt f l =
try
Some (find f l)
@@ -225,6 +225,7 @@ val flip : 'a list list -> 'a list list
*)
val combine_opt : 'a list -> 'b list -> ('a * 'b) list option
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
+val assq_opt : 'a -> ('a * 'b) list -> 'b option
val find_opt : ('a -> bool) -> 'a list -> 'a option
(**

0 comments on commit cb74acd

Please sign in to comment.