Commits

camlspotter committed e37771a

assoc_all

Comments (0)

Files changed (2)

   | [x] -> x
   | _::xs -> last xs
 
+let assoc_all k = 
+  let rec aux rev = function
+    | [] -> List.rev rev
+    | (k',v)::kvs when k = k' -> aux (v::rev) kvs
+    | _::kvs -> aux rev kvs
+  in
+  aux []
+  
 
 val find_opt : ('a -> bool) -> 'a list -> 'a option
 val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option
+val assoc_all : 'a -> ('a * 'b) list -> 'b list
 
 val filter_map : ('a -> 'b option) -> 'a list -> 'b list
 val concat_map : ('a -> 'b list) -> 'a list -> 'b list
   (** raises Failure when the argument is [].
       [last [1;2;3] = 3]
   *)
+