forked from andrejbauer/clerical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prelude.real
46 lines (33 loc) · 1.41 KB
/
prelude.real
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(* The Clerical prelude. This file gets loaded before anything
else, unless you use --no-prelude. *)
(* Definitions of built-in functions. These are implemented
in the OCaml code, here we just bind them to names. *)
(* Integer comparisons *)
external ( < ) : (int, int) -> bool = "<"
external ( > ) : (int, int) -> bool = ">"
external ( <= ) : (int, int) -> bool = "<="
external ( >= ) : (int, int) -> bool = ">="
external ( <> ) : (int, int) -> bool = "<>"
external ( == ) : (int, int) -> bool = "=="
(* Integer arithmetic *)
external ( - ) : (int, int) -> int = "-"
external ( + ) : (int, int) -> int = "+"
external ( * ) : (int, int) -> int = "*"
(* shift(a,k) computes a * 2^k in integer arithetic. *)
external shift : (int, int) -> int = "shift"
(* Logical connectives. *)
external ( ! ) : (bool) -> bool = "not"
(* Warning: these are *not* short-circuit, for those we need language support. *)
external ( && ) : (bool, bool) -> bool = "&&"
external ( || ) : (bool, bool) -> bool = "||"
(* Conversion *)
external real : (int) -> real = "real"
external int : (real) -> int = "int"
(* Real-valued arithmetic *)
external ( +. ) : (real, real) -> real = "+."
external ( /. ) : (real, real) -> real = "/."
external ( -. ) : (real, real) -> real = "-."
external ( *. ) : (real, real) -> real = "*."
(* Real-valued comparisons *)
external ( <. ) : (real, real) -> bool = "<."
external ( >. ) : (real, real) -> bool = ">."