From a249f2ac0b638a48bb3864c065e3589f4f9c3635 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 24 Dec 2017 17:10:02 +0100 Subject: [PATCH] missing compat functions --- src/core/CCList.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 27ab041e..a271f7cf 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -54,6 +54,16 @@ let rec compare_length_with l n = match l, n with (Pervasives.compare (length l)n)) *) +let rec assoc_opt x = function + | [] -> None + | (y,v) :: _ when Pervasives.(=) x y -> Some v + | _ :: tail -> assoc_opt x tail + +let rec assq_opt x = function + | [] -> None + | (y,v) :: _ when Pervasives.(==) x y -> Some v + | _ :: tail -> assq_opt x tail + (* end of backport *) include List