5 (define (make-table same-key?)
6 (let ((local-table (list '*table*)))
7 (define (assoc key records)
10 ((same-key? key (car (car records))) (car records))
11 (else (assoc key (cdr records)))))
13 (define (lookup key-1 key-2)
14 (let ((subtable (assoc key-1 (cdr local-table))))
16 (let ((record (assoc key-2 (cdr subtable))))
21 (define (insert! key-1 key-2 value)
22 (let ((subtable (assoc key-1 (cdr local-table))))
24 (let ((record (assoc key-2 (cdr subtable))))
26 (set-cdr! record value)
28 (cons (cons key-2 value)
37 ((eq? m 'lookup-proc) lookup)
38 ((eq? m 'insert-proc!) insert!)
39 (else (error "Unknown operation -- TABLE"))))
42 ;(define operation-table (make-table equal?))
43 ;(define get (operation-table 'lookup-proc))
44 ;(define put (operation-table 'insert-proc!))
47 > (define numeric-table
48 (make-table (lambda (key-1 key-2) (< (abs (- key-2 key-1)) 2))))
49 > (define get-val (numeric-table 'lookup-proc))
50 > (define put-val (numeric-table 'insert-proc!))