vault backup: 2023-09-11 23:41:53
This commit is contained in:
parent
206c76bd7c
commit
38f5bd8492
14
.obsidian/workspace.json
vendored
14
.obsidian/workspace.json
vendored
@ -11,8 +11,12 @@
|
|||||||
"id": "00ae67f71d1252f8",
|
"id": "00ae67f71d1252f8",
|
||||||
"type": "leaf",
|
"type": "leaf",
|
||||||
"state": {
|
"state": {
|
||||||
"type": "empty",
|
"type": "markdown",
|
||||||
"state": {}
|
"state": {
|
||||||
|
"file": "Algo/Séminaire/Exercices seminaire.md",
|
||||||
|
"mode": "source",
|
||||||
|
"source": false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -81,6 +85,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "backlink",
|
"type": "backlink",
|
||||||
"state": {
|
"state": {
|
||||||
|
"file": "Algo/Séminaire/Exercices seminaire.md",
|
||||||
"collapseAll": false,
|
"collapseAll": false,
|
||||||
"extraContext": false,
|
"extraContext": false,
|
||||||
"sortOrder": "alphabetical",
|
"sortOrder": "alphabetical",
|
||||||
@ -97,6 +102,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "outgoing-link",
|
"type": "outgoing-link",
|
||||||
"state": {
|
"state": {
|
||||||
|
"file": "Algo/Séminaire/Exercices seminaire.md",
|
||||||
"linksCollapsed": false,
|
"linksCollapsed": false,
|
||||||
"unlinkedCollapsed": true
|
"unlinkedCollapsed": true
|
||||||
}
|
}
|
||||||
@ -118,7 +124,9 @@
|
|||||||
"type": "leaf",
|
"type": "leaf",
|
||||||
"state": {
|
"state": {
|
||||||
"type": "outline",
|
"type": "outline",
|
||||||
"state": {}
|
"state": {
|
||||||
|
"file": "Algo/Séminaire/Exercices seminaire.md"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -133,6 +133,8 @@ val f : int -> int = <fun>
|
|||||||
# let succ x = x +1;;
|
# let succ x = x +1;;
|
||||||
val succ: int -> int = <fun>
|
val succ: int -> int = <fun>
|
||||||
|
|
||||||
|
(* these two functions are equivalent *)
|
||||||
|
|
||||||
# let succ = function x -> x + 1;;
|
# let succ = function x -> x + 1;;
|
||||||
val succ: int -> int = <fun>
|
val succ: int -> int = <fun>
|
||||||
```
|
```
|
||||||
@ -151,7 +153,7 @@ val avg : int -> int -> int = <fun>
|
|||||||
|
|
||||||
**For the match function**
|
**For the match function**
|
||||||
```Ocaml
|
```Ocaml
|
||||||
# let f x = watch x with
|
# let f x = match x with
|
||||||
| 0 -> 18
|
| 0 -> 18
|
||||||
| 1 -> 24
|
| 1 -> 24
|
||||||
| _ -> x*x ;;
|
| _ -> x*x ;;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
## Exercise 2.2 (Power)
|
|
||||||
|
|## Exercise 2.2 (Power)
|
||||||
|
|
||||||
```Ocaml
|
```Ocaml
|
||||||
(*First version ; 6 multiplications*)
|
(*First version ; 6 multiplications*)
|
||||||
@ -213,5 +214,23 @@ let price w (p1, p2, p3, p4) =
|
|||||||
val price = int -> 'a * 'a * 'a * 'a -> 'a = <fun>
|
val price = int -> 'a * 'a * 'a * 'a -> 'a = <fun>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Exercise 3.9
|
||||||
|
```Ocaml
|
||||||
|
let apm = function
|
||||||
|
| (0, 0) -> 2
|
||||||
|
| (0, y) -> 1
|
||||||
|
| (x, 0) -> 1
|
||||||
|
| (x, y) -> 0
|
||||||
|
| _ -> invalid_arg "Error";;
|
||||||
|
|
||||||
|
let strange = function
|
||||||
|
| (0, n) -> 0
|
||||||
|
| (m, 0) -> 2*m
|
||||||
|
| (m, n) -> m*n ;;
|
||||||
|
|
||||||
|
let or3 = function
|
||||||
|
| (a, false, false) -> "premier a"
|
||||||
|
| (false, b, false) -> "b"
|
||||||
|
| (false, false, c) -> "c" ;;
|
||||||
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user