(define (dispatch m)
(cond ((eq? m 'lookup) lookup)
((eq? m 'insert!) insert!)
((eq? m 'get) local-table)
(else (error "Unknown" m ))))
dispatch))
(define t (make-table))
((t 'insert!) '(a b c d1 e1) 1)
((t 'insert!) '(a b c d2) 'qoo)
((t 'insert!) '(a b c d1 e2) 2)
((t 'insert!) '(a b c d1 e3) 3)
(t 'get)
((t 'lookup) '(a b c d1 e1))
((t 'lookup) '(a b c d2))
((t 'lookup) '(a b c d1 e2))
((t 'lookup) '(a b c d1 e3))
결과:
ok
ok
ok
ok
(*table* (a (b (c (d2 . qoo) (d1 (e3 . 3) (e2 . 2) (e1 . 1))))))
1
qoo
2
3