Writing lambda functions in Scala

Posted by user2433237 on Stack Overflow See other posts from Stack Overflow or by user2433237
Published on 2014-06-06T21:23:51Z Indexed on 2014/06/06 21:24 UTC
Read the original article Hit count: 106

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about Scheme

Related posts about anonymous-function