From 80ef1158cc0ec28cb56721900a458c5cdc9a5357 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 12 Jul 2018 20:02:05 +0200 Subject: Simplify mem and memq Signed-off-by: Olivier Gayot --- my_list.mli | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'my_list.mli') diff --git a/my_list.mli b/my_list.mli index 0f5b71a..09a8b5e 100644 --- a/my_list.mli +++ b/my_list.mli @@ -78,19 +78,11 @@ let rec flatten = function (** Return true if the given elem is contained in the given list. *) let rec mem elem = function - | Item(hd, tl) -> ( - match hd = elem with - | true -> true - | false -> mem elem tl - ) + | Item(hd, tl) -> hd = elem || 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 - ) + | Item(hd, tl) -> hd == elem || memq elem tl | None -> false -- cgit v1.2.3