Writing lambda functions in Scala
- by user2433237
I'm aware that you can write anonymous functions in Scala but I'm having trouble trying to convert a piece of code from Scheme.
Could anyone help me convert this to Scala?
(define apply-env
(lambda (env search-sym)
(cases environment env
(empty-env ()
(eopl:error 'apply-env "No binding for ~s" search-sym))
(extend-env (var val saved-env)
(if (eqv? search-sym var)
val
(apply-env saved-env search-sym)))
(extend-env-rec (p-name b-var p-body saved-env)
(if (eqv? search-sym p-name)
(proc-val (procedure b-var p-body env))
(apply-env saved-env search-sym))))))
Thanks in advance