This is the mail archive of the guile@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] |
hjstein@bfr.co.il (Harvey J. Stein) writes: > How are hash tables supposed to work in guile? How good are they? > > In particular: > 1. How does one make a hash table? The manual talks about things > like hashq-ref, hashq-set! & hashq-remove!, but never says how to > make a hash table. This was surprising. Is it just a vector or > is it a separate type? one way: (define (make-hash) (make-array '() 431)) ; munge prime to taste yes, it's just a vector. > 2. Do they grow dynamically or does their size remain fixed? If they > remain of fixed size, are there any particular sizes that are most > efficient for the default hashing fcns? Also, if they remain of > fixed size, why?!?! I've always found the STk hash tables (based > on the TCL code) that grow dynamically to be extremely efficient & > convenient to use. they are fixed because they are implemented in user space as arrays. anyone is free to write `rehash'. > 3. What about mapping over a hash table? How can I get all the key > value pairs out of the hash table? Is the hash table a vector of > alists? It doesn't say anywhere, so there's no documented > mechanism/fixed API for doing such things. (ht->list HASH-TABLE) gives you a list of key/value pairs amenable to `map' or `for-each'. i found in the (old old) guile docs a section on the "dictionary convention" that was useful. dunno if that's still around somewhere. thi