From 3cbc1b2470bc1b774e76bd136a7c097521862a5e Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 2 Oct 2023 14:33:50 +0200 Subject: [PATCH] vault backup: 2023-10-02 14:33:50 --- Algo/Courses/Chapter 6 - Lists (Exercises).md | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) 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