diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index 95b58e3..d7eae56 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -1,8 +1,19 @@ -## 1.1 -```Ocaml -let product n = - if n = [] then +## 1.1 - Product + +``` +let rec product = function + | [] -> 0 + | x::t -> x + product t;; +``` +## 1.2 - Count +``` +let rec count x n = + if x = [] then 0 - else - let rec p = - \ No newline at end of file + else + let e::t = x + if e = x then + 1 + count t n + else + count t n +``` \ No newline at end of file