vault backup: 2023-09-14 16:20:59

This commit is contained in:
Louis Gallet 2023-09-14 16:20:59 +02:00
parent 371f88ff5b
commit 10c9f6b716
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
3 changed files with 37 additions and 9 deletions

View File

@ -13,7 +13,7 @@
"state": { "state": {
"type": "markdown", "type": "markdown",
"state": { "state": {
"file": "Algo/Séminaire/Chapter 4 - A bit of imperative.md", "file": "Algo/Séminaire/Chapter 5 - Recursivity.md",
"mode": "source", "mode": "source",
"source": false "source": false
} }
@ -85,7 +85,7 @@
"state": { "state": {
"type": "backlink", "type": "backlink",
"state": { "state": {
"file": "Algo/Séminaire/Chapter 4 - A bit of imperative.md", "file": "Algo/Séminaire/Chapter 5 - Recursivity.md",
"collapseAll": false, "collapseAll": false,
"extraContext": false, "extraContext": false,
"sortOrder": "alphabetical", "sortOrder": "alphabetical",
@ -102,7 +102,7 @@
"state": { "state": {
"type": "outgoing-link", "type": "outgoing-link",
"state": { "state": {
"file": "Algo/Séminaire/Chapter 4 - A bit of imperative.md", "file": "Algo/Séminaire/Chapter 5 - Recursivity.md",
"linksCollapsed": false, "linksCollapsed": false,
"unlinkedCollapsed": true "unlinkedCollapsed": true
} }
@ -125,7 +125,7 @@
"state": { "state": {
"type": "outline", "type": "outline",
"state": { "state": {
"file": "Algo/Séminaire/Chapter 4 - A bit of imperative.md" "file": "Algo/Séminaire/Chapter 5 - Recursivity.md"
} }
} }
}, },
@ -158,11 +158,11 @@
}, },
"active": "9e7be1904dfd4451", "active": "9e7be1904dfd4451",
"lastOpenFiles": [ "lastOpenFiles": [
"Algo/Séminaire/assets/unitaire-meme.png",
"Algo/Séminaire/Chapter 5 - Recursivity.md",
"Algo/Séminaire/Exercices seminaire.md",
"Algo/Séminaire/Chapter 4 - A bit of imperative.md", "Algo/Séminaire/Chapter 4 - A bit of imperative.md",
"Algo/Séminaire/Chapter 5 - Recursivity.md",
"Algo/Séminaire/Chapter 3 - Case analysis.md", "Algo/Séminaire/Chapter 3 - Case analysis.md",
"Algo/Séminaire/assets/unitaire-meme.png",
"Algo/Séminaire/Exercices seminaire.md",
"Algo/Séminaire/Introduction.md", "Algo/Séminaire/Introduction.md",
"Algo/Séminaire/Chapter 2 - Functions.md", "Algo/Séminaire/Chapter 2 - Functions.md",
"Algo/Séminaire/assets/fact function response.png", "Algo/Séminaire/assets/fact function response.png",
@ -185,7 +185,6 @@
"Mathématiques/Séminaire/Logics", "Mathématiques/Séminaire/Logics",
"Mathématiques/Séminaire/Logics/Pasted image 20230904101721.png", "Mathématiques/Séminaire/Logics/Pasted image 20230904101721.png",
"Mathématiques/Séminaire/Logics/Pasted image 20230904101453.png", "Mathématiques/Séminaire/Logics/Pasted image 20230904101453.png",
"Mathématiques/Séminaire/Logics/Pasted image 20230904100934.png",
"Mathématiques/Séminaire", "Mathématiques/Séminaire",
"2023-09-01.md", "2023-09-01.md",
"Algo", "Algo",

View File

@ -1,3 +1,5 @@
![](https://gitea.louisgallet.fr/lgallet/epicours/raw/branch/main/Algo/S%C3%A9minaire/assets/unitaire-meme.png)
## 0.1. Print ## 0.1. Print
If we want to print something in CAML, we have to use this structure If we want to print something in CAML, we have to use this structure

View File

@ -1,4 +1,5 @@
![Alt](https://gitea.louisgallet.fr/lgallet/epicours/raw/branch/main/Algo/S%C3%A9minaire/assets/recursivite-meme.png "recursivity problem")
<center><img src="https://gitea.louisgallet.fr/lgallet/epicours/raw/branch/main/Algo/S%C3%A9minaire/assets/recursivite-meme.png " width=512 height=auto /> </center>
### 5.1. Simple functions ### 5.1. Simple functions
To create a recursive function we have to use this structure To create a recursive function we have to use this structure
@ -64,3 +65,29 @@ A[ctd 3] --> B[ctd 2] --> C[ctd 1] --> D[ctd 0] --> E[ctd -1] --> F[ ] --> E -->
> ctd is countdown > ctd is countdown
## 5.3. Several recursive calls ## 5.3. Several recursive calls
A function that have several recursive calls is defind like this
$$
Fn = {1 -> \text{if } n\eqslantless{1} \brace{Fn+1+Fn+2} }
$$
**Fibonacci functions**
```Ocaml
let rec fibonacci n =
if n = 0 then
0
else if n = 1 then
1
else
fibonacci(n-1) + fibonacci(n-2);;
let add n =
if n = 0 then
false
else
even (n-1);;
let even n =
if n = 0 then
true
else
add (n-1);;
```