-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ml
58 lines (31 loc) · 877 Bytes
/
example.ml
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
47
48
49
50
51
52
53
54
55
56
57
58
open Orb
(* a new integer *)
let n = { a = { b = 2 } }
let () = puts (n.a.b + 3)
(* a new list *)
let v = []
let ocaml = "OCAML"
let is = "IS"
let awesome = "AWESOME!!!"
let list_of_strings = [ "hi"; "there" ]
(* calling methods *)
let () = list_of_strings.push awesome
let () = list_of_strings += is
let () = list_of_strings += ocaml
let () = v.push list_of_strings
let () = v.push [ "yo"; "pretty cool" ]
let () = puts v
(* a new file *)
let f = file "text.txt"
(* file operations *)
let () = f.puts "hi there!"
let () = puts ^ ("this was read from a file: (" + f.read + ")")
let () = puts ^ (5 + 5)
let () = f.remove
let name = "charles"
let () = puts ^ ("hi there, " + (name * 3) + "!!")
let () = puts ^ (10.2003 * 100.)
let o = { x = 1000; y = { z = 2 }; get_x = self.x }
let () = puts o.get_x
let () = puts o.y.z
let () = puts { var = 23 }.var