summaryrefslogtreecommitdiff
path: root/my_list.mli
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2018-07-11 21:31:04 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2018-07-11 21:31:04 +0200
commit20cf9db70e399954821ec1fc9bc0983d34a7682a (patch)
treece9ed0dc19a41964e7ed83d970596c7aaa74a399 /my_list.mli
parent12155c436f7e10ac0b5049554db8dba8779a1fe1 (diff)
Add the memq function
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'my_list.mli')
-rw-r--r--my_list.mli10
1 files changed, 10 insertions, 0 deletions
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