We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
; empty-env : () → Env (define empty-env (lambda () (lambda (op) (cond [(eqv? op 'envrionment?) #t] [(eqv? op 'empty?) #t] [(eqv? op 'search) (lambda (search-var) (eopl:error 'empty-env))] [else (eopl:error 'empty-env)]))))
; extend-env : Var × SchemeVal × Env → Env (define extend-env (lambda (saved-var saved-val saved-env) (lambda (op) (cond [(eqv? op 'envrionment?) #t] [(eqv? op 'empty?) #f] [(eqv? op 'search) (lambda (search-var) (if (eqv? search-var saved-var) saved-val (apply-env saved-env search-var)))] [else (eopl:error 'extend-env)]))))
; extend-env : Var × Var × Expression × Env → Env (define extend-env-rec (lambda (proc-name bound-var proc-body saved-env) (letrec ((env (lambda (op) (cond [(eqv? op 'envrionment?) #t] [(eqv? op 'empty?) #f] [(eqv? op 'search) (lambda (search-var) (if (eqv? search-var proc-name) (proc-val (procedure bound-var proc-body env)) (apply-env saved-env search-var)))] [else (eopl:error 'extend-env-rec)])))) env)))
; apply-env : Env × Var → SchemeVal (define apply-env (lambda (env search-var) ((env 'search) search-var)))
(define environment? (lambda (env) (if (procedure? env) (env 'envrionment?) #f)))
The text was updated successfully, but these errors were encountered:
chenyukang
No branches or pull requests
; empty-env : () → Env
(define empty-env
(lambda ()
(lambda (op)
(cond
[(eqv? op 'envrionment?) #t]
[(eqv? op 'empty?) #t]
[(eqv? op 'search)
(lambda (search-var)
(eopl:error 'empty-env))]
[else (eopl:error 'empty-env)]))))
; extend-env : Var × SchemeVal × Env → Env
(define extend-env
(lambda (saved-var saved-val saved-env)
(lambda (op)
(cond
[(eqv? op 'envrionment?) #t]
[(eqv? op 'empty?) #f]
[(eqv? op 'search)
(lambda (search-var)
(if (eqv? search-var saved-var)
saved-val
(apply-env saved-env search-var)))]
[else (eopl:error 'extend-env)]))))
; extend-env : Var × Var × Expression × Env → Env
(define extend-env-rec
(lambda (proc-name bound-var proc-body saved-env)
(letrec ((env
(lambda (op)
(cond
[(eqv? op 'envrionment?) #t]
[(eqv? op 'empty?) #f]
[(eqv? op 'search)
(lambda (search-var)
(if (eqv? search-var proc-name)
(proc-val (procedure bound-var proc-body env))
(apply-env saved-env search-var)))]
[else (eopl:error 'extend-env-rec)]))))
env)))
; apply-env : Env × Var → SchemeVal
(define apply-env
(lambda (env search-var)
((env 'search) search-var)))
(define environment?
(lambda (env)
(if (procedure? env)
(env 'envrionment?)
#f)))
The text was updated successfully, but these errors were encountered: