Tutorial by Examples

In OCaml, there are different arithmetic operators for floats and integers. Additionally, these operators can only be used on 2 floats or 2 integers. Here are invalid expressions in OCaml 1.0 + 2.0 1 + 2.0 1 +. 2 1 +. 2.0 The correct expression for each of these respectively are 1. +. 2. fl...
A common mistake is to forget surrounding compound function arguments with parentheses, leading to type errors. # string_of_int 1+1;; Error: This expression has type string but an expression was expected of type int This is because of the precedence. In fact, the above evaluates to # (string...

Page 1 of 1