This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
compilation/flap/src/utilities/dict.ml
2023-10-04 15:40:22 +02:00

25 lines
355 B
OCaml

type ('k, 'v) dict =
('k * 'v) list
type ('k, 'v) t = ('k, 'v) dict
let empty = []
let lookup k d =
try
Some (List.assoc k d)
with Not_found ->
None
let insert k v d =
(k, v) :: d
let to_list d = d
let of_list d = d
let equal d1 d2 =
List.for_all (fun (k, v) ->
lookup k d2 = Some v
) d1
&& List.(length d1 = length d2)