-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.ml
More file actions
33 lines (29 loc) · 692 Bytes
/
Module.ml
File metadata and controls
33 lines (29 loc) · 692 Bytes
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
module MyModule = struct
let inc x = x+1
type primary_color = Red | Green | Blue
exception Oops
end;;
sig
val inc: int -> int
type primary_color = Red | Green | Blue
exception Oops
end;;
module ListStack = struct
let empty = []
let is_empty = function [] -> true | _-> false
let push x s = x::s
exception Empty
let peek = function
| [] -> raise Empty
| x :: _-> x
let pop = function
|[] -> raise Empty
|_::s -> s
end;;
ListStack.push 2 (ListStack.push 1 ListStack.empty);;
ListStack.(push 2 (push 1 empty))
;;
ListStack.(empty |> push 1 |> push 2);;
let s1 = ListStack.(empty |> push 1 |> push 2)
let s2 = ListStack.(empty |> push 3)
;;