let rec list_fold_left2 f map a l1 l2 = match l1, l2 with
| [], [] -> f a
| hd1 :: tl1, hd2 :: tl2 ->
- let f a = if a = None then f a else list_fold_left2 f map a tl1 tl2 in
+ let f a = list_fold_left2 f map a tl1 tl2 in
map f a hd1 hd2
- | _ -> f None
+ | _ -> assert false
+
+let rec list_mem ?(eq=(=)) a = function
+ | [] -> false
+ | hd :: _ when eq a hd -> true
+ | _ :: tl -> list_mem ~eq a tl