-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.ml
More file actions
37 lines (24 loc) · 748 Bytes
/
env.ml
File metadata and controls
37 lines (24 loc) · 748 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
34
35
36
37
module CmpInt =
struct
type t = int
let compare = Stdlib.compare
end
module IntMap = Map.Make(CmpInt)
type env = Type.term IntMap.t
let empty () = IntMap.empty
let add env id v = IntMap.add id v env
let add_all env ids vals = List.fold_left2 (fun res id v -> IntMap.add id v res) env ids vals
let create l = List.fold_left (fun res (id, v) -> IntMap.add id v res) IntMap.empty l
let find env id = IntMap.find id env
let defined env id = IntMap.mem id env
let map env f = IntMap.map f env
let equal env1 env2 = IntMap.equal (=) env1 env2
let iter env f1 f2 =
IntMap.iter
(fun id t ->
f1 id;
f2 t;
Printf.printf "\n")
env
let filter env f = IntMap.filter (fun x _ -> f x) env
let size = IntMap.cardinal