Accessing table items

Scheme Procedure: hash-table-ref table key [default-thunk]
Scheme Procedure: hash-table-ref/default table key default

Answer the value associated with key in table. If key is not present, answer the result of invoking the thunk default-thunk, which signals an error instead by default.

hash-table-ref/default is a variant that requires a third argument, default, and answers default itself instead of invoking it.

Scheme Procedure: hash-table-set! table key new-value

Set key to new-value in table.

Scheme Procedure: hash-table-delete! table key

Remove the association of key in table, if present. If absent, do nothing.

Scheme Procedure: hash-table-exists? table key

Answer whether key has an association in table.

Scheme Procedure: hash-table-update! table key modifier [default-thunk]
Scheme Procedure: hash-table-update!/default table key modifier default

Replace key’s associated value in table by invoking modifier with one argument, the old value.

If key is not present, and default-thunk is provided, invoke it with no arguments to get the “old value” to be passed to modifier as above. If default-thunk is not provided in such a case, signal an error.

hash-table-update!/default is a variant that requires the fourth argument, which is used directly as the “old value” rather than as a thunk to be invoked to retrieve the “old value”.