From 20cf9db70e399954821ec1fc9bc0983d34a7682a Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 11 Jul 2018 21:31:04 +0200 Subject: Add the memq function Signed-off-by: Olivier Gayot --- my_list.mli | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/my_list.mli b/my_list.mli index 329efba..0f5b71a 100644 --- a/my_list.mli +++ b/my_list.mli @@ -84,3 +84,13 @@ let rec mem elem = function | false -> mem elem tl ) | None -> false + +(** Return true if the given elem is contained in the given list. Same as + * my_list.mem but uses physical equality. *) +let rec memq elem = function + | Item(hd, tl) -> ( + match hd == elem with + | true -> true + | false -> memq elem tl + ) + | None -> false -- cgit v1.2.3