This is the mail archive of the mailing list for the guile project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Hash table keys?

Lauri Alanko <> writes:

> On Sun, Mar 28, 1999 at 02:16:21PM -0800, it occurred to Greg Badros to write:
> > How do I get at a list of the keys in a guile hash table?  Is there a
> > standard supported proc (e.g., hash-table->alist would be nice)?
> (define (hash-table->alist h)
>   (apply append (vector->list h)))

Nice and simple, but this exploits implementation details of the
hash-table that I as the end-user of the hash-table ADT shouldn't need
to be aware of (for that matter, perhaps a dictionary is a better
abstraction to provide).  This proc needs to be provided by guile,
perhaps along with the obvious helpers to get at the keys and values
with map car/cdr from the alist.