You can represent an environment, a procedure that maps symbols to values
as a function for example, the roman environment is
(define roman-fun
(lambda (y)
(cond
((eq? y 'I) 1)
((eq? y 'V) 5)
((eq? y 'X) 10)
((eq? y 'L) 50)
((eq? y 'C) 100)
((eq? y 'D) 500)
((eq? y 'M) 1000)
(else (error)))))
And then define lookup like this
(define lookup
(lambda (y env)
(env y))))
> (lookup 'X roman-fun) ==> 10
> (lookup 'Z roman-fun) ==> error.
or as a data structure:
(define roman-data
'((I . 1) (V . 5) (X . 10) (L . 50) (C . 100) (D . 500) (M . 1000))
(define lookup
(lambda (y env)
(cond
((null? env) (error))
((eq? (car (car env)) y) (cdr (car env)))
(else (lookup y (cdr env)))))
> (lookup 'X roman-data) ==> 10
> (lookup 'Z roman-data) ==> error.
... Dan