Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Should be INSIDE STANDARD-LIB: Hashtbl.keys
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-21 (01:40)
From: oliver@f...
Subject: [Caml-list] Should be INSIDE STANDARD-LIB: Hashtbl.keys

I think a good addition to the Hashtbl-module
would be a function, that gives back a list of keys
that are in the hash.

Well, ok, I've written code for doing this task,
before I've mailed this idea to the list,
so I'm not looking for code / for help with sources here.

I only think, this is such an often used function, that
it should be integrated into the Hastbl-module.

Well, should be something like this one:

           val keys : ('a, 'b) t -> 'a list

      Hashtbl.keys <hash>  returns a list of all keys of the
      hash "hash", that exists and therefore have values bound
      to it. If a key has several bindings, it will occur only
      once in this list.

IMHO it should be possible to implement a Hashtbl.keys function
inside the Hashtbl-module-sources much more efficient than
doing it via the already given Hashtbl-functions of that module,
that are exported.

But even if this would not be true, I think, giving back a list of
all keys in a hash (with each key reported only once, even if it has
more than one binding) is a rudimentary and necessary function,
that should be integrated in the standard-Hashtbl-Lib-module.

Best regards to all OCaml core developers (and all other readers too) here.

   Oliver Bandel

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: