Generalizing one- and two-dimensional tables

Generalizing one- and two-dimensional tables, show how to implement a table in which values are stored under an arbitrary number of keys and different values may be stored under different numbers of keys. The lookup and insert! should take as input a list of keys used to access the table.


There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(define t (make-table))

(insert! '(a) 5 t)
(insert! '(a b) 10 t)
(insert! '(a b c) 42 t)

(check-equal? (lookup '(a) t) 5)
(check-equal? (lookup '(a b) t) 10)
(check-false (lookup '(b) t))
(check-equal? (lookup '(a b c) t) 42)