I'd like to ask if you can help me with a programming exercise. I'm trying to make a lambda expression of this form:
λz.x(yz)
The way I understand this, is that y is a function, applied to the value z. Then x is a function applied to what comes out if the function y is applied to z. The whole expression then says this:
λz.x(yz) means: Do the following with the argument z:
- Apply the function
ytoz. - Apply the function
xto what comes out of the first procedure.
I've made this program to try to get Scheme to do all of the above:
(define (zlamb)
(lambda (z)
(lambda (x)
(* (lambda (y) (* z 4)) 2))))
When I run it, all I get is this:
Welcome to DrRacket, version 5.3 [3m].
Language: R5RS; memory limit: 128 MB.
( (zlamb) 3)
procedure:...lambdaefing1.rkt:3:4
>
Can anybody please explain to me what I'm doing wrong? What I wanted to get is (3 * 4) * 2 = 24. So I made (or thought I made) the inner function y = z * 4 and the outer function x = y(z) * 2.
I've searched all over the internet for explanations, but can't find the particular needle I'm looking for in the haystack.