vault backup: 2023-10-06 14:06:29

This commit is contained in:
2023-10-06 14:06:29 +02:00
parent 8ff68b2f15
commit 30bfc996c9
2 changed files with 14 additions and 19 deletions

View File

@ -54,16 +54,11 @@ let rec nth x n =
## 1.5 - Maximum
```Ocaml
let max l =
if l = [] then
0
else
let maxi = 0
let rec m =
let e::t = l
if e >= maxi then
maxi = e
else
m t
let rec max_value list = match list with
| [] -> failwith "La liste est vide"
| [x] -> x
| hd :: tl ->
let max_tail = max_value tl in
if hd > max_tail then hd else max_tail;;
```