类型

和其他语言一样,有 int, float, char, string, bool 等等.

Operations of Type

^ 字符串拼接,*. 浮点数相乘,"xxxxx".[0] 从字符串中取字符

在 OCaml 里判断相等用 =<>,而不用 ==!=.

类型转换

  • <target>_of_<source> 类型转换

Assertions

1
let () = assert (f input1 = output1)

流程控制

条件语法

1
if e1 then e2 else e3

类型检查:若 e1:bool\texttt{e1}: \texttt{bool}e2,e3:t\texttt{e2,e3}: \texttt{t},则整个表达式为 t\tt t

Let 语法

1
let x = e1 in e2