http://gashe.info/tmp/cours-ocaml-paris8-2020.org
good-eris.net/formation-ocaml
let nom = expression ;;
;;
= fin du message
let message = "..." ^ nom
let bonjour name =
"Bonjour " ^ name
avec : (name : string)
\Rightarrow type défini
if x >= 0 then x else (-x)
Commentaire : (* ... *)
let square = fun x -> x * x
list.map f (1, 2, 3) (* applique la fonction f à la liste : (f(1); f(2); f(3)) *)
tuple : (..., ..., ...)
type address =
Telephone of int * string (* ex : (.., "..") *)
Nom of string
Email of string
Exercice :
let categorie address = (* underscore : ne se nomme pas *)
match address with
| Email mail (* mail = nom *) -> "email"
| Telephone (_, _) -> "numéro"