diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-07-11 21:30:50 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-07-11 21:30:50 +0200 |
commit | 12155c436f7e10ac0b5049554db8dba8779a1fe1 (patch) | |
tree | 0c133ee4c29e4d8ed35aa30f3361e7a097af10e3 | |
parent | 54031d742675d9bab6bbf7621434cc2476135a1e (diff) |
Add the mem function
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r-- | my_list.mli | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/my_list.mli b/my_list.mli index 4644a74..329efba 100644 --- a/my_list.mli +++ b/my_list.mli @@ -75,3 +75,12 @@ let rev_append l1 l2 = let rec flatten = function | Item(hd, tl) -> append hd (flatten tl) | None -> None + +(** 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 + ) + | None -> false |