Question

I have problems understanding lambda calculus operators precedence.

For example the following code:

lambda x.x z lambda y.x y

is going to be:

lambda x. (x (z lambda y. x y))

or

lambda x. ((x z) (lambda y. x y))

?

Even more complicated examples:

(lambda x.x z) lambda y.w lambda w.w x y z

where in the above example the parentheses go ?

I know that lambda application is left associative but does lambda values have higher precedence over applications?

Was it helpful?

Solution

Application has higher precedence than abstraction. Together with the fact that application is left-associative and abstraction is right-associative, this leads to the following:

lambda x.x z lambda y.x y

is

lambda x. ( (x z) (lambda y. (x y)) )

and

(lambda x.x z) lambda y.w lambda w.w x y z

is

(lambda x. (x z)) (lambda y. (w (lambda w. (((w x) y) z))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top