diff options
author | Son HO | 2022-10-21 11:14:15 +0200 |
---|---|---|
committer | GitHub | 2022-10-21 11:14:15 +0200 |
commit | b4be489e7a5753bcc7f8714273ae71260fac53ce (patch) | |
tree | 45459740595bcdd70e5f4856b8499d1680d4ab91 /src/Collections.ml | |
parent | 53a2b8a2989485e8885d02c786206de84c9fd91d (diff) | |
parent | d62563cf9b8ef29ce20e810a5b1da999122c7a2f (diff) |
Merge pull request #4 from AeneasVerif/son_update_charon
Update the code to account for changes in Charon
Diffstat (limited to 'src/Collections.ml')
-rw-r--r-- | src/Collections.ml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Collections.ml b/src/Collections.ml index 2cb298a7..351b6523 100644 --- a/src/Collections.ml +++ b/src/Collections.ml @@ -184,6 +184,7 @@ module type Set = sig val pp : Format.formatter -> t -> unit val show : t -> string + val pairwise_distinct : elt list -> bool end module MakeSet (Ord : OrderedType) : Set with type elt = Ord.t = struct @@ -218,6 +219,19 @@ module MakeSet (Ord : OrderedType) : Set with type elt = Ord.t = struct pp_string "}" let show s = to_string None s + + let pairwise_distinct ls = + let s = ref empty in + let rec check ls = + match ls with + | [] -> true + | x :: ls' -> + if mem x !s then false + else ( + s := add x !s; + check ls') + in + check ls end (** A map where the bindings are injective (i.e., if two keys are distinct, |