diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-07-11 21:31:04 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-07-11 21:31:04 +0200 |
commit | 20cf9db70e399954821ec1fc9bc0983d34a7682a (patch) | |
tree | ce9ed0dc19a41964e7ed83d970596c7aaa74a399 | |
parent | 12155c436f7e10ac0b5049554db8dba8779a1fe1 (diff) |
Add the memq function
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r-- | my_list.mli | 10 |
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 |