Question:
((lambda (x y) (x y)) (lambda (x) (* x x)) (* 3 3))
This was #1 on the midterm, I put ’81 9′ he thought I forgot to cross one out lawl, so I cross out 81, and he goes aww. Anyways, I dont understand why it’s 81.
I understand why (lambda (x) (* x x)) (* 3 3) = 81, but the first lambda I dont understand what the x and y values are there, and what the [body] (x y) does.
So I was hoping someone could explain to me why the first part doesn’t seem like it does anything.
This needs some indentation to clarify
(lambda (x y) (x y)); callxwithyas only parameter.(lambda (x) (* x x)); evaluate to the square of its parameter.(* 3 3); evaluate to 9So the whole thing means: ‘call the square function with the 9 as parameter’.
EDIT: The same thing could be written as
I guess the intent of the exercise is to highlight how evaluating a scheme form involves an implicit function application.