From 54031d742675d9bab6bbf7621434cc2476135a1e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 11 Jul 2018 21:16:00 +0200 Subject: Add the flatten (concat) function Signed-off-by: Olivier Gayot --- my_list.mli | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'my_list.mli') diff --git a/my_list.mli b/my_list.mli index 72535d5..4644a74 100644 --- a/my_list.mli +++ b/my_list.mli @@ -70,3 +70,8 @@ let rec append l1 l2 = (** Return a list which results in the concatenation of reversed l1 and l2. *) let rev_append l1 l2 = append (rev l1) l2 + +(** Return a list consisting of the contenation of the given list of lists. *) +let rec flatten = function + | Item(hd, tl) -> append hd (flatten tl) + | None -> None -- cgit v1.2.3