epicours/Algo/Courses/Chapter 6 - Lists (Exercises).md

19 lines
227 B
Markdown

## 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 e::t = x
if e = x then
1 + count t n
else
count t n
```