vault backup: 2023-10-02 14:45:43
This commit is contained in:
parent
3cbc1b2470
commit
8d5cfa14dc
21
.obsidian/workspace.json
vendored
21
.obsidian/workspace.json
vendored
@ -18,21 +18,8 @@
|
|||||||
"source": false
|
"source": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "accf3e9b23e83334",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "markdown",
|
|
||||||
"state": {
|
|
||||||
"file": "Algo/Courses/Chapter 6 - Lists (Exercises).md",
|
|
||||||
"mode": "source",
|
|
||||||
"source": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"currentTab": 1
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"direction": "vertical"
|
"direction": "vertical"
|
||||||
@ -169,10 +156,11 @@
|
|||||||
"command-palette:Open command palette": false
|
"command-palette:Open command palette": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"active": "accf3e9b23e83334",
|
"active": "88e153f7ea61ad97",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
"Algo/Courses/Chapter 6 - Lists.md",
|
"Algo/Séminaire/Chapter 3 - Case analysis.md",
|
||||||
"Algo/Courses/Chapter 6 - Lists (Exercises).md",
|
"Algo/Courses/Chapter 6 - Lists (Exercises).md",
|
||||||
|
"Algo/Courses/Chapter 6 - Lists.md",
|
||||||
"Algo/Courses",
|
"Algo/Courses",
|
||||||
"Algo/Séminaire/Exercices seminaire.md",
|
"Algo/Séminaire/Exercices seminaire.md",
|
||||||
"Algo/CM/CM du 27 septembre.md",
|
"Algo/CM/CM du 27 septembre.md",
|
||||||
@ -193,7 +181,6 @@
|
|||||||
"COM-ADMR",
|
"COM-ADMR",
|
||||||
"Methodologie",
|
"Methodologie",
|
||||||
"Algo/Séminaire/Chapter 4 - A bit of imperative.md",
|
"Algo/Séminaire/Chapter 4 - A bit of imperative.md",
|
||||||
"Algo/Séminaire/Chapter 3 - Case analysis.md",
|
|
||||||
"Algo/Séminaire/Introduction.md",
|
"Algo/Séminaire/Introduction.md",
|
||||||
"Algo/Séminaire/Chapter 1 - CAML basics.md",
|
"Algo/Séminaire/Chapter 1 - CAML basics.md",
|
||||||
"Algo/Séminaire/assets/exception-meme.png",
|
"Algo/Séminaire/assets/exception-meme.png",
|
||||||
|
@ -11,9 +11,43 @@ let rec count x n =
|
|||||||
if x = [] then
|
if x = [] then
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
let e::t = x
|
let e::t = x in
|
||||||
if e = x then
|
if e = x then
|
||||||
1 + count t n
|
1 + count t n
|
||||||
else
|
else
|
||||||
count t n
|
count t n;;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.3 - Search
|
||||||
|
```
|
||||||
|
let rec search x n =
|
||||||
|
if x = [] then
|
||||||
|
0
|
||||||
|
else
|
||||||
|
let e::t = x in
|
||||||
|
if e = x then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
search t n;;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.4 - $n^{th}$
|
||||||
|
```
|
||||||
|
let rec length l =
|
||||||
|
if l = [] then
|
||||||
|
0
|
||||||
|
else
|
||||||
|
let e::t = l in
|
||||||
|
1 + length t;;
|
||||||
|
let rec nth x n =
|
||||||
|
if (x = [] || n =< 0) then
|
||||||
|
Invalid_arg "The number of element in the list is 0"
|
||||||
|
else if length x < n then
|
||||||
|
Failwith "The list is too short"
|
||||||
|
else
|
||||||
|
let e::t = x in
|
||||||
|
if e = x then
|
||||||
|
1 + count t n
|
||||||
|
else
|
||||||
|
count t n;;
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user