vault backup: 2023-10-06 14:52:29
This commit is contained in:
parent
890ea1b07b
commit
aa40e475bc
@ -54,7 +54,7 @@ val search 'a -> 'a list -> bool = <fun>
|
|||||||
| (_::t, n) -> nthrec(t, n-1)
|
| (_::t, n) -> nthrec(t, n-1)
|
||||||
in
|
in
|
||||||
ntrec(l, n);;
|
ntrec(l, n);;
|
||||||
val nth 'a list -> 'a -> int = <fun>
|
val nth 'a list -> int -> 'a = <fun>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -66,6 +66,18 @@ val nth 'a list -> 'a -> int = <fun>
|
|||||||
| hd :: tl ->
|
| hd :: tl ->
|
||||||
let max_tail = max_value tl in
|
let max_tail = max_value tl in
|
||||||
if hd > max_tail then hd else max_tail;;
|
if hd > max_tail then hd else max_tail;;
|
||||||
|
|
||||||
|
(* v2 *)
|
||||||
|
# let max_value list =
|
||||||
|
if list = [] then
|
||||||
|
failwith "la list est vide"
|
||||||
|
else
|
||||||
|
let rec mv = match list with
|
||||||
|
| [x] -> x
|
||||||
|
| hd :: tl ->
|
||||||
|
let max_tail = max_value tl in
|
||||||
|
if hd > max_tail then hd else max_tail
|
||||||
|
in mv list;;
|
||||||
```
|
```
|
||||||
|
|
||||||
## 1.6 - Bonus second
|
## 1.6 - Bonus second
|
||||||
@ -90,7 +102,7 @@ val nth 'a list -> 'a -> int = <fun>
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Exercise 2.1
|
## Exercise 2.1
|
||||||
```Ocaml
|
```
|
||||||
let rec arith_list n a r =
|
let rec arith_list n a r =
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user