12.  Tables

      unroff provides simple hash tables as a new first class data type table. Each table entry associates an arbitrary Scheme object with a key (a Scheme string or symbol). Tables are useful for various purposes; for example, the Scheme code delivered with unroff maintains hash tables to store information about number registers, options, fonts, and for other bookkeeping tasks.

(table? obj)

      The type predicate for the new type; it returns #t if obj is a member of the type table, otherwise #f.

(make-table size)

      Returns a new table of the specified size. size is a positive integer. The smaller the size, the more collisions occur as entries are added to the table. However, the hash function employed by the table primitives ensures that no collisions occur in tables of size 256^n if all keys have a length less than or equal to n.

(table-store! table key obj)

      This primitive stores the Scheme object obj under the given key in the given table. The key argument must be a string or a symbol.

(table-lookup table key)

      This primitive checks whether an object is stored in the given table under the specified key, and if so, returns the object. If no object is stored under key, table-lookup returns #f.

(table-remove! table key)

      Removes the entry selected by key from the specified table.


Markup created by unroff 1.0,    March 21, 1996,    net@informatik.uni-bremen.de