Question: Here we restrict our lambdas to have only one argument. The lexical address of a variable is the number of lambdas between the place where

Here we restrict our lambdas to have only one argument. The lexical address of a
variable is the number of lambdas between the place where the variable is bound (also
known as the formal) and the place where it occurs. For example, in the following
expression:
( lambda (0)
( lambda (r)
( lambda (s)
( lambda (p)
( lambda (g)
o)))))
The o at the very bottom is a bound occurrence. It has a lexical address of 4, because
there are four lambda expressions between the formal o at the top and the occurrence
of o at the bottom.
Define and test a procedure lex that takes a lambda-calculus expression and an
accumulator (which starts as the empty list), and returns the same expression with all
bound variable references replaced by lists of two elements whose first member is the
symbol var and whose second member is the lexical address of the referenced variable.
You should leave free variables as is.
lex '( lambda (x)x
'())
(lambda (var0))
>( lex '( lambda (y)(lambda (x) y))
'())
( lambda (lambda (var 1)))
lex '( lambda lambda (x)(xy)
'())
(lambda (lambda ((var0)(var1))
lex '(lambda (x)(lambda (x)(x,x)
'())
( lambda (lambda ((var0)(var0))
lex '(lambda lambda (x)(yx)
'())
(lambda (lambda (y(var0))'())
lambda lambda ((var0)(var1)) lambda (((var2)(var1)))
 Here we restrict our lambdas to have only one argument. The

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!