vault backup: 2023-10-02 14:18:14
This commit is contained in:
8
Algo/Courses/Chapter 6 - Lists (Exercises).md
Normal file
8
Algo/Courses/Chapter 6 - Lists (Exercises).md
Normal file
@ -0,0 +1,8 @@
|
||||
## 1.1
|
||||
```Ocaml
|
||||
let product n =
|
||||
if n = [] then
|
||||
0
|
||||
else
|
||||
let rec p =
|
||||
|
@ -108,3 +108,12 @@ val t: int list = [2; 3]
|
||||
1 +. length t;;
|
||||
Warning : pattern matching not exhaustive
|
||||
val length: 'a list -> int = <fun>
|
||||
|
||||
# let rec length = function
|
||||
| [] -> 0
|
||||
| _::t -> 1 + length t;;
|
||||
(* with this solution there is no warning *)
|
||||
val length : 'a list -> int = <fun>
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user