Skip to content

Commit

Permalink
add printer for VarSet
Browse files Browse the repository at this point in the history
  • Loading branch information
ghilesZ committed Oct 9, 2024
1 parent 6fbba61 commit be56485
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/misc/tools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ module VarMap = struct
(** builds the list of all the keys of the map *)
let keys map = fold (fun k _ acc -> k :: acc) map []

(** prints bindings of the map, using pp_v for to print each value, and
calling pp_sep between items (pp_sep defaults to Format.pp_print_cut). *)
(** prints bindings of the map, using pp for to print each value, and calling
pp_sep between items (pp_sep defaults to Format.pp_print_cut). *)
let print ?pp_sep pp fmt m =
Format.pp_print_list ?pp_sep
(fun fmt (k, v) -> Format.fprintf fmt "%s%a" k pp v)
Expand All @@ -79,4 +79,13 @@ end

let list_pick l = List.nth l (Random.int (List.length l))

module VarSet = Set.Make (String)
module VarSet = struct
include Set.Make (String)

(** prints map, using pp_v for to print each value, and calling pp_sep between
items (pp_sep defaults to Format.pp_print_cut). *)
let print ?pp_sep pp fmt s =
Format.pp_print_list ?pp_sep
(fun fmt v -> Format.fprintf fmt "%a" pp v)
fmt (elements s)
end

0 comments on commit be56485

Please sign in to comment.