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.

— procedure: **2d-put!**` x-key y-key datum`

Makes an entry in the association table that associates

datumwithx-keyandy-key. Returns an unspecified result.

— procedure: **2d-remove!**` x-key y-key`

If the association table has an entry for

x-keyandy-key, it is removed. Returns an unspecified result.

— procedure: **2d-get**` x-key y-key`

Returns the

datumassociated withx-keyandy-key. Returns`#f`

if no such association exists.

— procedure: **2d-get-alist-x**` x-key`

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 forx-keyexist.(2d-put! 'foo 'bar 5) (2d-put! 'foo 'baz 6) (2d-get-alist-x 'foo) => ((baz . 6) (bar . 5))

— procedure: **2d-get-alist-y**` y-key`

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 fory-keyexist.(2d-put! 'bar 'foo 5) (2d-put! 'baz 'foo 6) (2d-get-alist-y 'foo) => ((baz . 6) (bar . 5))