This is the mail archive of the guile@sourceware.cygnus.com 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: how to work with (weak) hash tables?


Valentin Kamyshenko <val@kamysh.materials.kiev.ua> writes:

> Hello,
> 
> is there a way to loop over all members of (weak) hash table?

Sure. The easiest way (at least, what I think is the easiest way :) is
to convert it to an alist using hash-fold;

(define hash-table->alist
  (lambda (tab)
     (hash-fold acons () tab)))

Then you just do whatever you'd do for an alist.

> It seems to be necessary, for example, for saving/restoring hash
> tables (although my problem is different).
> 
> Thank you in advance,
> 
> --
> Best regards,
> 	Valentin.
> 
> 

-- 
Greg

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