suppose I have the following functions:
(define (g x) (f x))
(define (f x) (+ 1 x))
I would like to temporarily call g
with a different f
. For example, something like this:
(let ((f (lambda (x) (+ 2 x))))
(g 5))
I would like the code above to evaluate to 7, but it doesn't. Instead, it evaluates to 6, since g
calls the f
outside the scope of the let
.
Is there a way to do this without redefining g
inside the let
, and without inlining the entire body of the definition of g
in the let
? (In practice, g
may be a very large, complicated function).