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:

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

sorry if I'm late, but anyway.

the function that you need is called `hash-fold'.

(define ht (make-hash-table 7))

(hashq-set! ht 'a 1)
(hashq-set! ht 'b 2)

(hash-fold (lambda (key value acc)
             (display (list key value))
             (newline)
             (+ 1 acc))
           0 ht)
 ===>
(a 1)
(b 2)
2

> 	Valentin.

--mike

-- 
Politics is non-euclidean.                           -- Robert Anton Wilson

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