Next: Hash Tables, Previous: 1D Tables, Up: Associations
MIT/GNU Scheme provides a generalization of the property-list mechanism
found in most other implementations of Lisp: a global two-dimensional
association table. This table is indexed by two keys, called
x-key and y-key in the following procedure descriptions.
These keys and the datum associated with them can be arbitrary objects.
eq?
is used to discriminate keys.
Think of the association table as a matrix: a single datum can be accessed using both keys, a column using x-key only, and a row using y-key only.
Makes an entry in the association table that associates datum with x-key and y-key. Returns an unspecified result.
If the association table has an entry for x-key and y-key, it is removed. Returns an unspecified result.
Returns the datum associated with x-key and y-key. Returns
#f
if no such association exists.
Returns an association list of all entries in the association table that are associated with x-key. The result is a list of
(
y-key.
datum)
pairs. Returns the empty list if no entries for x-key exist.(2d-put! 'foo 'bar 5) (2d-put! 'foo 'baz 6) (2d-get-alist-x 'foo) => ((baz . 6) (bar . 5))
Returns an association list of all entries in the association table that are associated with y-key. The result is a list of
(
x-key.
datum)
pairs. Returns the empty list if no entries for y-key exist.(2d-put! 'bar 'foo 5) (2d-put! 'baz 'foo 6) (2d-get-alist-y 'foo) => ((baz . 6) (bar . 5))