vault backup: 2023-10-06 16:00:48

This commit is contained in:
2023-10-06 16:00:48 +02:00
parent 9fff9089fa
commit c19e9679c6
3 changed files with 34 additions and 8 deletions

View File

@ -78,6 +78,14 @@ val nth 'a list -> int -> 'a = <fun>
let max_tail = max_value tl in
if hd > max_tail then hd else max_tail
in mv list;;
(* Correction *)
let maximum = function
[] -> invalid_arg "Pas bô"
| e::t ->
(let rec max_rec m = function
[]-> m
|e::t -> max_rec (if e>m then e else m) t in max_rec e t);;
```
## 1.6 - Bonus second

View File

@ -117,3 +117,22 @@ val length : 'a list -> int = <fun>
```
```mermaid
flowchart LR
A[l] --> |h::t| B[m < h ? ]
B --> C[m<-h] & D[keep m]
A --> |"[]"| E[m]
```
## Build/modify a list
### Construction method
```Ocaml
# let rec what = function
0 -> []
| n -> n::what(n-1);;
val what : int -> int list = <fun>
# what 3;;