OCaml is a value-based; strongly, statically, implicitly typed; functional programming language
~-
operator# 1001 / 365 ;; (* # of years in 1001 nights *)
- : int = 2
# 1001 mod 365 ;; (* # of nights left over *)
- : int = 271
# 1001 - (1001 / 365) * 365 ;; (* ...or alternatively *)
- : int = 271
# 3.14 ;;
- : float = 3.14
# 314e-2 ;;
- : float = 3.14
# 0x1.91eb851eb851fp+1 ;;
- : float = 3.14
# "" ^ "first" ^ " and second" ;;
- : string = "first and second"
# if 3 = 3 then 0 else 1 ;;
- : int = 0
# 2 * if 3 > 4 then 3 else 4 + 5 ;;
- : int = 18
# 2 * (if 3 > 4 then 3 else 4) + 5 ;;
- : int = 13
OCaml is a typed language
, meaning that every expression of the language is associated with a type; specifically, OCaml is statically typed
, in that the type of an expression can be determined just by examining the expression in its context. On the other hand, Python is dynamically typed
, meaning that it is necessary to run the code in which an expression occurs in order to determine the type of an expression