summaryrefslogtreecommitdiff
path: root/my_list.mli
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2018-07-11 21:30:50 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2018-07-11 21:30:50 +0200
commit12155c436f7e10ac0b5049554db8dba8779a1fe1 (patch)
tree0c133ee4c29e4d8ed35aa30f3361e7a097af10e3 /my_list.mli
parent54031d742675d9bab6bbf7621434cc2476135a1e (diff)
Add the mem function
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'my_list.mli')
-rw-r--r--my_list.mli9
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