Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no BatHashtbl.for_all #1067

Open
UnixJunkie opened this issue Jan 7, 2022 · 2 comments
Open

no BatHashtbl.for_all #1067

UnixJunkie opened this issue Jan 7, 2022 · 2 comments

Comments

@UnixJunkie
Copy link
Member

This is inconsistent with many other modules: List, Map, Array.
And yes, sometimes you need to check something about all key-value pairs in a hashtbl...

@UnixJunkie
Copy link
Member Author

exception Falsified

(* test if predicate holds for all key-value pairs *)
let ht_for_all ht p =
  try
    Ht.iter (fun k v ->
        if not (p k v) then
          raise Falsified
      ) ht;
    true
  with Falsified -> false

@UnixJunkie
Copy link
Member Author

If we have a for_all, we probably should have an exists too.

@UnixJunkie UnixJunkie self-assigned this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant