This question seems curious and interesting to me. So, I'm trying to understand what lambda calculus is, find the answer and want to show its OP (all the hints have already been shown in fact, a spoiler alert ).
First, try overriding f :
Îģ> let f = (\gxyz -> x^3 - g(x + g(y - gz) + g(z^2))) f :: (Integer -> Integer) -> Integer -> Integer -> Integer -> Integer
So, we have a function that receives a function and 3 numbers and returns a response. Using curring, we can add the definition of g right here, for example f_new = fg :
Îģ> let f = (\gxyz -> x^3 - g(x + g(y - gz) + g(z^2))) (\x -> 2*x^2 + 10*x + 1) f :: Integer -> Integer -> Integer -> Integer
We are done. Let it check:
Îģ> f 0 0 0 -13
The answer is correct.
UPD
In these examples, let is just a way of declaring a function in the interpreter, so the final answer is:
f :: Num a => a -> a -> a -> a f = (\gxyz -> x^3 - g(x + g(y - gz) + g(z^2))) (\x -> 2*x^2 + 10*x + 1)
DMITRY MALIKOV
source share