This is a collection of small functions I found handy to have.
The newest version of the library is 0.1. It can be obtained from http://practical-scheme.net/vault/hashutils-0.1.tar.gz.
If you read this document off-line, check out the newest document online. http://practical-scheme.net/vault/hashutils.html.
Once you get the package, you can install it by the following procedure.
cd hashutils
stk Makefile.stk
make install
To use the functions, load and import hashutils module:
(require "hashutils") (import hashutils)
Or, if you're using modutils,
(use-module hashutils)
A hash table is created by (apply make-hash-table INITARGS)
.
Then, given KEY
and VALUE
pairs are inserted to the
hash table. It is an error to give a KEY
without accompanying
VALUE
.
(define *command-table* (hash-table () 'help (list help "show help") 'quit (list (lambda () (exit 0)) "quit program") 'ls (list cmd-list "list elements"))) (define *abbrev-table* (hash-table `(,equal?) "RCS" "Revision Control System" "CVS" "Concurrent Versions System"))
HASH
.
For each key-value pair of the hash table, a procedure PROC
is
called with three arguments: a key, a value, and a partial result
returned by the previous call of PROC
. For the first key-value
pair, INIT
is passed as the third argument. Returns
the result of the last call of PROC
.
For example, the following call returns a list of keys whose value equals "N/A".
(hash-table-fold *table* (lambda (k v r) (if (equal? value "N/A") (cons k r) r)) '())
HASH
.
VALUE
to the current value of KEY
in a hash table
HASH
. If no value is associated to the key, (list VALUE)
is put as the value.
Jump to: h
This document was generated on 17 October 2000 using texi2html 1.56k.