Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be the lambda definition of let in Scheme / Racket? [duplicate]

Today I am trying to understand how let works in context of lambda calculus in Scheme / Racket, but I can't figure out how to write the equivalent of let as a lambda function.

I think that the general form of it should be something like this:

((lambda (p1 p2...) body) v1 v2...)

but definitely that's not a complete function definition.

Any ideas of correct/complete definition for that?

Thank you in advance!

like image 679
Filip Ion Dorinel Avatar asked Oct 16 '25 03:10

Filip Ion Dorinel


1 Answers

From R5RS, the definition of let is:

(define-syntax let
  (syntax-rules ()
    ((let ((name val) ...) body1 body2 ...)
      ((lambda (name ...) body1 body2 ...)
        val ...))
    ((let tag ((name val) ...) body1 body2 ...)
      ((letrec ((tag (lambda (name ...)
                       body1 body2 ...)))
        tag)
      val ...))))
like image 148
user448810 Avatar answered Oct 18 '25 23:10

user448810