Commits

camlspotter committed 62cf8cd

added List.find_opt

  • Participants
  • Parent commits a9910b6

Comments (0)

Files changed (2)

File lib/xlist.ml

   in
   from_to [] f t
 
+let find_opt f ls = try Some (List.find f ls) with Not_found -> None 
+
 let rec find_map_opt f = function
   | [] -> None
   | x::xs ->

File lib/xlist.mli

 val from_to : int -> int -> int list
   (** [from_to f t = [f..t]] *)
 
+val find_opt : ('a -> bool) -> 'a list -> 'a option
 val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option
 val filter_map : ('a -> 'b option) -> 'a list -> 'b list