vault backup: 2023-09-12 15:26:21

This commit is contained in:
2023-09-12 15:26:21 +02:00
parent 32c1a6dec9
commit 615167f073
3 changed files with 54 additions and 25 deletions

View File

@ -1,16 +0,0 @@
If we want to print something in CAML, we have to use this structure
```Ocaml
# print_string "Hello World!";;
Hello! - : unit=()
# print_int ;;
-: int -> unit = <fun>
(*expression*)
# print_[type] [things to print];;
[things to print] -: unit=()
```
[![](https://mermaid.ink/img/pako:eNpFjsEKwjAQRH8lLOLJ_kAPguixvejReFiSrQ002bJuUCn9d9OKOKfhMczMBI49QQ3dwE_Xo6hpzjaZouOhbUxVGcdxDAMVuzebq7ktjF7kVvBQTB7FV5x1zGq2f0IiLLCDSBIx-LIxLcUWtKdIFupiPXWYB7Vg01yimJUv7-SgVsm0gzx6VDoFvAvGHyQflKX93l7fzx9XV0DK?type=png)](https://mermaid.live/edit#pako:eNpFjsEKwjAQRH8lLOLJ_kAPguixvejReFiSrQ002bJuUCn9d9OKOKfhMczMBI49QQ3dwE_Xo6hpzjaZouOhbUxVGcdxDAMVuzebq7ktjF7kVvBQTB7FV5x1zGq2f0IiLLCDSBIx-LIxLcUWtKdIFupiPXWYB7Vg01yimJUv7-SgVsm0gzx6VDoFvAvGHyQflKX93l7fzx9XV0DK)

View File

@ -0,0 +1,43 @@
## 0.1. Print
If we want to print something in CAML, we have to use this structure
```Ocaml
# print_string "Hello World!";;
Hello! - : unit=()
# print_int ;;
-: int -> unit = <fun>
(*expression*)
# print_[type] [things to print];;
[things to print] -: unit=()
```
**Difference between compiler and interpreter for print**
```mermaid
flowchart LR
A[CAML] -- compile --> B[ ] -- exec --> C[standard output] & D[standard error] ~~~ E(on your terminal)
```
```mermaid
flowchart LR
A[CAML] -- interpreter --> B[standard error] & C[standard output] & D[CAML answer] ~~~ E(in the interpreter interface)
```
**To print something and create a new line for the CAML evaluation**
```Ocaml
# print_endline "toto";;
toto
-: unit = ()
```
**To just print a newline**
```Ocaml
# print_newline();;
-: unit = ()
```
## 0.2. Sequence of prints
```Ocaml
# print_string "The answer is: "; print_int 42;;
The answer is: 42 -: unit = ()