Next: The Association Table, Previous: Association Lists, Up: Associations
1D tables (“one-dimensional” tables) are similar to association
lists. In a 1D table, unlike an association list, the keys of the table
are held weakly: if a key is garbage-collected, its associated
value in the table is removed. 1D tables compare their keys for
equality using eq?
.
1D tables can often be used as a higher-performance alternative to the two-dimensional association table (see The Association Table). If one of the keys being associated is a compound object such as a vector, a 1D table can be stored in one of the vector's slots. Under these circumstances, accessing items in a 1D table will be comparable in performance to using a property list in a conventional Lisp.
Returns
#t
if object is a 1D table, otherwise returns#f
. Any object that satisfies this predicate also satisfieslist?
.
Creates an association between key and datum in 1d-table. Returns an unspecified value.
Removes any association for key in 1d-table and returns an unspecified value.
Returns the datum associated with key in 1d-table. If there is no association for key, default is returned.
If-found must be a procedure of one argument, and if-not-found must be a procedure of no arguments. If 1d-table contains an association for key, if-found is invoked on the datum of the association. Otherwise, if-not-found is invoked with no arguments. In either case, the result of the invoked procedure is returned as the result of
1d-table/lookup
.