vault backup: 2023-09-05 15:20:49

This commit is contained in:
2023-09-05 15:20:49 +02:00
parent 6dfa2cb3bc
commit 053d5c2f60
5 changed files with 29 additions and 11 deletions

View File

@ -73,3 +73,5 @@ val pred: int -> int = <fun>
# square_of_pred 3;;
_: int = 4 (*same things but with another method*)
```
## 2.3. Function with several parameters (2 or more)

View File

@ -1,4 +1,4 @@
## 2.2 (Power)
## Exercise 2.2 (Power)
```Ocaml
(*First version ; 6 multiplications*)
@ -25,13 +25,29 @@
sq(sq(p4))*sq(p4)*p4;;
```
## 2.3
## Exercise 2.3
![[F1D2AA19-E790-4022-AFFF-F778EAB28AB5.jpg]]
```Ocaml
# (*my verison*)
# let mirror(n) = let diz = n/10 and uni = n mod 10 in uni*10 + diz;;
val mirror : int -> int = <fun>
# (*teatcher version*)
# let mirror n = 10 *(n mod 10)+n/10;;
val mirror : int -> int = <fun>
```
```Ocaml
# let abba(n) = n*100 + mirror(n) ;;
val abba: int -> int = <fun>
```
```Ocaml
# let stammer(n) = abba(mirror(n)) * 10 000 + abba(n) ;;
val stammer: int -> int = <fun>
```
![[69E2987C-209A-48CD-8964-5A60462966E5.jpg]]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB