#lang eopl
(define-datatype env env?
(empty-env)
(extended-env (var symbol?)
(val scheme-val?)
(envi env?)))
(define (scheme-val? x) #t)
; examples
(define e-env (empty-env))
(define e1 (extended-env 'x 1 (extended-env 'y #f e-env)))
I don’t get how scheme-val? is used. Why is there an x, and why are we returning #t?
Environment is a function associating a variable with a value.
So in the example, we are associating x = 1, and y = #f, right?
Thanks.
In scheme,
#tis means boolean true,#fbeing false. I don’t fully understand the rest, but I suggest DrRacket’s debugger to see what’s going on.assigns
e-envto be anempty-envdefines an anonymous function that takes a parameter
x, and if it is ascheme-val(in this case, anything), returns#t.The result of
e1after this code runs is:so
e1is anextended-env with var='x, val=1, envi=(extended-env with var='y, val=#f, envi=e-env)(I think)