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

This commit is contained in:
2023-09-14 16:20:59 +02:00
parent 371f88ff5b
commit 10c9f6b716
3 changed files with 37 additions and 9 deletions

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
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
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
## 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);;
```