/scheme-hashtable

An implementation of a hash table written in portable Scheme

Primary LanguageSchemeGNU General Public License v3.0GPL-3.0

scheme-hashtable

An implementation of a hash table written in portable Scheme

Copyright

scheme-hashtable is free software licensed under the GNU General Public License version 3 or later.

Portability

scheme-hashtable should run in any R4RS+ conformant Scheme.

scheme-hashtable is known to work on:

Example

(define foo (hash-tableq 'foo "foo" 'bar "bar"))
(hash-table-ref foo 'foo) ;; ===> (foo . "foo")
(hash-table-ref foo 'bar) ;; ===> (bar . "bar")
(hash-table-set! foo 'bar "baz")
(hash-table-ref foo 'bar) ;; ===> (bar . "baz")

API Reference

Procedure: (make-hash-table)

Procedure: (make-hash-tableq)

Procedure: (make-hash-tablev)

Create and return a new hash table using equal?, eq? or eqv? respectively for comparison of keys. All hash tables are mutable. Optionally takes a size as an argument.

Procedure: (hash-table? obj)

Return #t if obj is a hash table.

Procedure: (hash-table-equal? obj)

Procedure: (hash-table-eq? obj)

Procedure: (hash-table-eqv? obj)

Return #t if obj is a hash table using equal?, eq? or eqv? respectively for comparison of keys.

Procedure: (hash-table-set! ht key val)

Set key in the hash table ht to val.

Procedure: (hash-table-ref ht key)

Lookup the value of key in the hash table ht. If ht has key, return the pair of key and the value, else return #f.

Procedure: (hash-table-delete! ht key)

Remove key from the hash table ht.

Procedure: (alist->hash-table alist)

Procedure: (alist->hash-tableq alist)

Procedure: (alist->hash-tablev alist)

Convert the associative list alist to a hash table using equal?, eq? or eqv? respectively for comparison of keys.

Procedure: (hash-table->alist ht)

Convert the hash table ht to an associative list.

Procedure: (hash-table args ...)

Procedure: (hash-tableq args ...)

Procedure: (hash-tablev args ...)

Construct a hash table using equal?, eq? or eqv? respectively for comparison of keys.

Procedure: (hash-table-aproc ht)

Get assoc, assq or assv depending on which procedure the hash table ht uses.

Procedure: (hash-table-pred ht)

Get the predicate the hash table ht uses for comparison of keys.

Procedure: (hash-table-copy ht)

Create a copy of the hash table ht.

Procedure: (hash-table-set ht args ...)

Create a copy of the hash table ht and set the keys to the values.

Procedure: (hash-table-delete ht keys ...)

Create a copy of the hash table ht and delete the keys.