These are generic hash tables, and are in the structure tables
.
Strictly speaking they are more maps than tables, as every table has a
value for every possible key (for that type of table).
All but a finite number of those values are #f
.
(make-table) -> table
(make-symbol-table) -> symbol-table
(make-string-table) -> string-table
(make-integer-table) -> integer-table
(make-table-maker compare-proc hash-proc) -> procedure
(make-table-immutable! table)
Make-table
returns a table whose keys may be symbols, integer,
characters, booleans, or the empty list (these are also the values
that may be used in case
expressions).
As with case
, comparison is done using eqv?
.
The comparison procedures used in symbol, string, and integer tables are
eq?
, string=?
, and =
.
Make-table-maker
takes two procedures as arguments and returns
a nullary table-making procedure.
Compare-proc
should be a two-argument equality predicate.
Hash-proc
should be a one argument procedure that takes a key
and returns a non-negative integer hash value.
If (
returns true,
then compare-proc
x
y
)(= (
must also return true.
For example, hash-proc
x
) (hash-proc
y
))make-integer-table
could be defined
as (make-table-maker = abs)
.
Make-table-immutable!
prohibits future modification to its argument.
(table? value) -> boolean
(table-ref table key) -> value or #f
(table-set! table key value)
(table-walk procedure table)
Table?
is the predicate for tables.
Table-ref
and table-set!
access and modify the value of key
in table
.
Table-walk
applies procedure
, which must accept two arguments,
to every associated key and non-#f
value in table
.
Default-hash-function
is the hash function used in the tables
returned by make-table
, and string-hash
it the one used
by make-string-table
.
Previous: Finite record types | Next: Port extensions