Short answer, by currying the x
parameter. Something like this:
(define twoback
(lambda (f)
(lambda (x)
...))) ; fill-in with the logic requested
The above will define a procedure called twoback
which receives f
as parameter, and in turn it will return a new procedure which receives x
as parameter. This second procedure being returned is the one called g
in the question, from it you can access both f
and x
as you would normally do.
Now just complete the ...
part with the expected output.