vault backup: 2023-10-06 14:06:29
This commit is contained in:
@ -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;;
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user