vault backup: 2023-09-07 16:08:59
This commit is contained in:
parent
ac1facb185
commit
a2fbc3a53b
10
.obsidian/workspace.json
vendored
10
.obsidian/workspace.json
vendored
@ -13,7 +13,7 @@
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Algo/Séminaire/Exercices sémaines.md",
|
||||
"file": "Algo/Séminaire/Chapter 3 - Case analysis.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
@ -85,7 +85,7 @@
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Algo/Séminaire/Exercices sémaines.md",
|
||||
"file": "Algo/Séminaire/Chapter 3 - Case analysis.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
@ -102,7 +102,7 @@
|
||||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Algo/Séminaire/Exercices sémaines.md",
|
||||
"file": "Algo/Séminaire/Chapter 3 - Case analysis.md",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
@ -125,7 +125,7 @@
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Algo/Séminaire/Exercices sémaines.md"
|
||||
"file": "Algo/Séminaire/Chapter 3 - Case analysis.md"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@
|
||||
"command-palette:Open command palette": false
|
||||
}
|
||||
},
|
||||
"active": "c473a791e2b34194",
|
||||
"active": "bdba25946b821d06",
|
||||
"lastOpenFiles": [
|
||||
"Algo/Séminaire/Exercices sémaines.md",
|
||||
"Algo/Séminaire/Chapter 3 - Case analysis.md",
|
||||
|
@ -49,3 +49,28 @@ Exception: Invalid_argument "oops"
|
||||
else a/b ;;;
|
||||
val div int -> int -> int = <fun>
|
||||
```
|
||||
|
||||
## 3.3. Filtering
|
||||
### Explicit filtering
|
||||
|
||||
> Explicit means that you matches the value
|
||||
|
||||
|
||||
**General syntax**
|
||||
|
||||
```Ocaml
|
||||
match expr with pattern1 -> result1 | pattern2 -> result2 | ... | patternn -> resultn
|
||||
```
|
||||
> All expressions and pattern must avec the same type
|
||||
|
||||
**Example**
|
||||
```Ocaml
|
||||
# let f x = match x with
|
||||
0 -> 18
|
||||
1 -> 24
|
||||
y -> y + y;;
|
||||
|
||||
val f : int -> int = <fun>
|
||||
|
||||
# f 1;;
|
||||
- : int = 24
|
||||
|
@ -163,6 +163,9 @@ val max4 : 'a -> 'a -> 'a -> 'a -> 'a = <fun>
|
||||
```
|
||||
### Exercise 3.4
|
||||
```Ocaml
|
||||
let highest_square_sum x1 x2 x3 = let bigger = max3(x1 x2 x3) and middle = middle3(x1 x2 x3) in (bigger*bigger, middle*middle)
|
||||
let highest_square_sum x y z =
|
||||
let sq x = x*x in
|
||||
sq(max3 x y z) + sq(middle3 x y z)
|
||||
val highest_square_sum : int -> int -> int -> int = <fun>
|
||||
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user