Premiers pas en OCaml/Annexe/Synthèse
Aller à la navigation
Aller à la recherche
| Type | Signification | Représentation | Modèle:Fait Exemples | Modèle:Non Erreurs |
|---|---|---|---|---|
| int | Entier | [1] ou [2] |
-42 1337 0x539 0o2471 0b10100111001 |
0o8 : non octal 1. : mauvais type 1073741824 : dépassement entier |
| float | Réel, flottant | Entre et | -1. 137 |
0 : mauvais type 0,42 : pas de virgule 0x1. : impossible |
| char | Caractère | Entre '\000' et '\255' | 'c' '\n' '0' |
'cd' : trop de caractères |
| string | Chaîne de caractères | Tableau de mots de Modèle:Unité [1] ou Modèle:Unité [2] |
"chaine de caractères" "c" "1337" |
|
| bool | Booléen | true false |
||
| unit | Unité | () | ||
| Intervalle | Précision des réels |
|---|---|
| ∪ |
| Opération | Fonction | Type |
|---|---|---|
| Addition | + | int -> int -> int
|
| +. | float -> float -> float
| |
| Soustraction | - | int -> int -> int
|
| -. | float -> float -> float
| |
| Multiplication | * | int -> int -> int
|
| *. | float -> float -> float
| |
| Division euclidienne | / | int -> int -> int
|
| Division exacte | /. | float -> float -> float
|
| Modulo | mod | int -> int -> int
|
| mod_float | float -> float -> float
| |
| Racine carrée | sqrt | float -> float
|
| Puissance | ** | float -> float -> float
|
| Exponentielle | exp | float -> float
|
| Logarithme népérien | log | float -> float
|
| Logarithme | log10 | float -> float
|
| Cosinus | cos | float -> float
|
| Sinus | sin | float -> float
|
| Tangente | tan | float -> float
|
| Arc cosinus | acos | float -> float
|
| Arc sinus | asin | float -> float
|
| Arc tangente | atan | float -> float
|
| Nom | Fonction | Type |
|---|---|---|
| Conversion | int_of_float | float -> int
|
| float_of_int | int -> float
| |
| (float) | int -> float
| |
| int_of_char | char -> int
| |
| char_of_int | int -> char
| |
| string_of_bool | bool -> string
| |
| bool_of_string | string -> bool
| |
| int_of_string | string -> int
| |
| string_of_int | int -> string
| |
| float_of_string | string -> float
| |
| string_of_float | float -> string
| |
| Lecture | read_line | unit -> string
|
| read_int | unit -> int
| |
| read_float | unit -> float
| |
| Affichage | print_char | char -> unit
|
| print_int | int -> unit
| |
| print_float | float -> unit
| |
| print_string | string -> unit
| |
| print_endline | string -> unit
| |
| print_newline | unit -> unit
| |
| Concaténation | ^ | string -> string -> string
|
| Argument | Sys.argv.(int) | string
|
| Sys.argv | string array
|
| Structure | Type | Exemple |
|---|---|---|
| Liste | 'a list
|
[1; 2; 3]
|
| Tableau | 'a array
|
[| 1; 2; 3 |]
|
| Tuple | int * char
|
(2, 'e')
|
| Variant | type vt = A | B of int
|
A
B 6
|
| Enregistrements | type person = { name:string; age:int }
|
{ name="Alphonse"; age=32 }
someone.name
|